title: How do I remove the default headers just for specific XHR requests in AngularJS?
body: <p>99% of my ajax calls need a specific "X-API-TOKEN" to authenticate and communicate with my Rails REST API. But I'm also making a call to one thrid party API and I keep getting an error saying "Request header field X-API-TOKEN is not allowed by Access-Control-Allow-Headers."</p>
  
  <p>Everything works fine if I delte the header right before the call, and a work around would be to delete and then re-add after the call, but is there an easier way than this:</p>
  
  <pre><code>    apiToken = $http.defaults.headers.common["X-API-TOKEN"]
      delete $http.defaults.headers.common["X-API-TOKEN"]
  
      $http(
        method: "GET"
        url: 'http://...}}'
      ).success((data, status, headers, config) -&gt;
      ).error (data, status, headers, config) -&gt;
  
      $http.defaults.headers.common["X-API-TOKEN"] = apiToken
  </code></pre>