AngularJS $resource, internet explorer and authorization header

1,193 views
Skip to first unread message

siriss

unread,
Dec 17, 2012, 8:58:16 AM12/17/12
to ang...@googlegroups.com
Hi

I hava en angularjs web app with login form. The app uses $resource for sending requests to server on another domain. I am putting the user name and password into Authorization header like so: $http.defaults.headers.common['Authorization'] = "Basic " + Base64.encode(credentials); before calling the service. This works fine in firefox, chrome and safari but not in internet explorer 9 and 8. IE10 is working. IE 9 and 8 does not send anything to the server unless I set $http.defaults.useXDomain = true - but even with this set the Authorization header is stripped off. But this causes IE 10 to fail. The server responds with http status 401 and WWW-Authenticate header, but no additional request with Authorization header is set.

I really appreciate if someone has a solution to this or some hints to how I could solve this problem. 

Best regards
siriss

Pawel Kozlowski

unread,
Dec 18, 2012, 4:08:59 AM12/18/12
to ang...@googlegroups.com
Hi!

On Mon, Dec 17, 2012 at 2:58 PM, siriss <siren...@gmail.com> wrote:
> I set $http.defaults.useXDomain = true

There is no such option in AngularJS.

If you are trying to do the CORS request with the IE8,9 than this
won't work since $http service doesn't support XDomainRequest:
https://github.com/angular/angular.js/issues/934

and there is no hope that it will:
https://github.com/angular/angular.js/pull/1047

If need to support cross-origin requests with IE than your best option
is to setup proxing on your server and avoid cross-origin requests.

Cheers,
Pawel

--
Question? Send a fiddle
(http://jsfiddle.net/pkozlowski_opensource/Q2NpJ/) or a plunk
(http://plnkr.co/)
Need help with jsFiddle? Check this:
http://pkozlowskios.wordpress.com/2012/08/12/using-jsfiddle-with-angularjs/

Looking for UI widget library for AngularJS? Here you go:
http://angular-ui.github.com/
Reply all
Reply to author
Forward
0 new messages