lucassp lucassp - 8 months ago 60
Javascript Question

Setting application wide HTTP headers in AngularJS

Is there a way to set the

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.

$http.defaults.headers.common['Auth-Token'] = 'token';

It seems headers() normalizes the key names.