Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Is there a way to set the $httpProvider headers outside of angular.module('myApp', []).config()?

I'm getting an Auth-Token from the server after I login the user, and I need to add it as a HTTP Header to all following requests.

share|improve this question

1 Answer

up vote 1 down vote accepted
$http.defaults.headers.common['Auth-Token'] = 'token';

It seems headers() normalizes the key names.

share|improve this answer
Can you elaborate on what you mean by normalizes the key names? – Webnet Apr 16 at 15:40
When getting the headers using the headers() method, the key "Auth-Token" gets lowercased and becomes "auth-token". Which is confusing. – lucassp Apr 17 at 8:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.