title: How to add header for all RESTAdapter ember requests
body: <p>The API needs to specify api version <code>application/vnd.api+json;version=1</code>, also it needs secure x-app-id and x-app-secret. Is there a way to specify that in RESTAdapter in Ember?</p>
  
  <p>After Trying request header</p>
  
  <pre><code>App.Adapter = DS.RESTAdapter.extend({
    namespace: 'api',
    beforeSend: function(xhr) {
      xhr.setRequestHeader('x-my-custom-header', 'some value');
    }
  })
  </code></pre>
  
  <h1>SOLUTION</h1>
  
  <pre><code>App.Adapter = DS.RESTAdapter.extend({
    bulkCommit: true,
    namespace: 'api',
    headers: { 
     'Accept': 'application/vnd.app+json;version=1',
     'x-appid': '2375498237',
     'x-secret': '238945298235236236236236375923'
    },
    ajax: function(url, type, hash) {
      if (this.headers !== undefined) {
        var headers = this.headers;
        hash.beforeSend = function (xhr) {
          Ember.keys(headers).forEach(function(key) {
            xhr.setRequestHeader(key, headers[key]);
          });
        };
      }
      return this._super(url, type, hash);
    }
  });
  
  App.Store = DS.Store.extend({ adapter: App.Adapter.create() }); 
  App.Store = App.Store.create();
  </code></pre>
  
  <h1>UPDATE #2</h1>
  
  <p>The solution mentioned above is no longer needed, as Ember now supports this behavior by default. You only need to supply <code>headers</code> and it will automatically be added. </p>
  
  <p>Check out the docs here <a href="http://emberjs.com/guides/models/connecting-to-an-http-server/#toc_custom-http-headers" rel="noreferrer">http://emberjs.com/guides/models/connecting-to-an-http-server/#toc_custom-http-headers</a></p>