Communication between AngularJS and a Jersey Webservice which are on a different domain. Can't access correct session Communication between AngularJS and a Jersey Webservice which are on a different domain. Can't access correct session angularjs angularjs

Communication between AngularJS and a Jersey Webservice which are on a different domain. Can't access correct session


Depending on the version of AngularJS you are using you might have to set it on each $http.

Since 1.2 you can do:

$http.get(url,{ withCredentials: true, ...})

From 1.1.1 you can globally configure it:

config(['$httpProvider', function($httpProvider) {  $httpProvider.defaults.withCredentials = true;}]).

If you're using an older version of Angular, try passing a config object to $http that specifies withCredentials. That should work in versions before 1.1:

$http({withCredentials: true, ...}).get(...)

See also mruelans answer and:


just an update to @iwein anwser, that we can now set in config itself

config(['$httpProvider', function($httpProvider) {  $httpProvider.defaults.withCredentials = true;}]).

https://github.com/angular/angular.js/pull/1209

(available only after unstable version: 1.1.1)


In 1.2 version, this doesn't work for me:

$http({withCredentials: true, ...}).get(...) 

if I read the doc, the shortcut method should take the config object

$http.get(url,{ withCredentials: true, ...})

$http is a singleton, That's the only way to mix in a same application requests with and without credentials.