I'm setting a couple of default headers using $http.defaults.headers.common for communication with our API – e.g. the Authorization header. This saves me a lot of trouble of specifying these headers on every individual $http request or $resource declaration.
However, in one place I'm making an $http.get call to the Foursquare API and the fact that the additional headers exist is a problem a) obviously I don't want to send the authorization header to anything other than our API and b) the existence of the headers forces $http to use CORS and Foursquare rejects the OPTIONS request.
Is there any way I can set the defaults on a per-host basis or using some other context? I've tried moving the directive that contacts Foursquare into its own module hoping the defaults might be isolated that way but they're not.
I guess I can delete the additional headers from $http.defaults prior to the Foursquare request and restore them afterwards but it feels like a horrible hack and might be problematic if any requests to our API are attempted while waiting for the Foursquare response to come back.
{headers:{Authorization:null}}to the$http.getthe request still gets pre-flighted so that doesn't work.