Setting application wide HTTP headers in AngularJS

angularjs, javascript, mvvm

Solution

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

It seems `headers()` normalizes the key names.

Problem

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.

Original source

Related problems