Created
August 7, 2013 16:47
-
-
Save mariojunior/6175849 to your computer and use it in GitHub Desktop.
AngularJS Learned Lessons #2: Enabling HTTP Credentials (needed by Session IDs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//On config definition... | |
angular.module("moduleName").config( | |
function ($routeProvider, $httpProvider) { | |
//HERE THE IMPORTANT MAGIC LINE! | |
$httpProvider.defaults.withCredentials = true; | |
//If you don't set the line above, all $http will dispatch request without session_id to backend | |
//and the backend will not reconize the user session, giving your a big head pain! Believe on me. | |
//Question & Answer: http://stackoverflow.com/questions/17064791/http-doesnt-send-cookie-in-requests | |
//continue the configuration setting your routing definitions... blablabla... | |
$routeProvider | |
//Index and global pages | |
.when('/', { controller: IndexCtrl, templateUrl: TEMPLATE_DIR + 'main/login.html' }) | |
//.... set your routings definitions... | |
.otherwise({redirectTo: '/notFound'}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment