How can I update the common HTTP headers at runtime from an AngularJS controller, e.g. $httpProvider.defaults.headers.common['Authorization']
? It seems $httpProvider
can only be accessed from a config module, but I need to update common HTTP headers for all future requests from a controller, or a service called by the controller.
I can update the locally scoped headers for the next request by injecting $http
into my controller, but I need to do update HTTP headers for all future requests, specifically for basic authentication.
Session
service, but then I have to inject that service into every controller that does an HTTP request and set the common$http
Authorization header many times. And somewhere I will forget. Can you provide any code samples? – pate 2 days ago$http
in your controllers/services you can inject your http wrapper. In this service you could have a method to set the authorization. – jackdbernier yesterday