Hapijs + Angularjs cookie session with correct cors configuration not working -


here cors config in hapijs app:

    "connections": [         {             "port": 8067,             "routes": {                 "cors": {                     "credentials": true,                     "origin": ["*"]                 }             }         }     ], 

i using hapi-auth-cookie authenticate user post angular.js front-end. once login happens, sending request out list of projects, request projects returns 401.

here angular setup:

$http.get('http://localhost:8067/projects', {withcredentials: true})                         .success(function(data) {                             deferred.resolve(data);                         }).error(function(data,status,error,config){                             deferred.reject(data);                         }); 

it appears there's issue angular $http module (see: https://github.com/angular/angular.js/blob/master/src/ng/http.js#l929-l931) if pass in withcredentials $http.get('url_here', config) (config part of call), never gets set.

instead, fix this, use code: $http.defaults.withcredentials = true;


Comments