I can't seem to send $http.post
requests for authentication. My code matches the solution on this page AngularJS withCredentials but I get this error through my browser console.
Credentials flag is 'true', but the 'Access-Control-Allow-Credentials' header is ''. It must be 'true' to allow credentials.
This is what the code looks like:
$scope.authenticate = function (user, pass) {
$http.post(authUrl, {
username: user,
password: pass
}, {
withCredentials: true
})
}
I'm still new to angularJS but I read another site for help on setting custom headers, so I could fix the error message regarding the header. I tried to use:
$httpProvider.defaults.headers.post = { 'Access-Control-Allow-Credentials' : 'true' }
but I can't seem to get it right without $httpProvider undefined
errors. I put it above the $http.post
call, and also in the controller's function scope:
.controller("authCtrl", function($scope, $http, authUrl, $httpProvider) {
Any ideas?