I need a clean way to specify header data like XSFR tokens and authorization stuff in $http.
Something like this:
$http.defaults.headers.common["Auth_token"] = token;
But then all requests, also to other domains are populated with this header. Then, this fix came, that made sure only same domain received this header. https://github.com/angular/angular.js/issues/1096
Now I'm left with the problem that my server is on another domain (api.example.com), and only this, or other whitelisted servers should get specific headers.
I would love to be able to specify domains for which some headers are targeted for.
$http.defaults.headers.['api.trusted.com']['Auth_token'] = token;
Or similar. Have anyone else solved a similar problem?
In the latest version of AngularJS you could use freshly-introduced request interceptors to achieve desired results.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With