title: How do you set global custom headers in Angular2?
body: <p>I want to set the header <code>Content-type: application/json</code> in all my requests to my backend in Angular2. I use this in my main <code>app.js</code> file.</p>
  
  <pre><code>let headers = new Headers({
      'Content-Type', 'application/json'
  })
  class MyOptions extends BaseRequestOptions {
    headers: headers 
  }
  
  bootstrap(App, [
    provide(RequestOptions, {useClass: MyOptions}),
    ROUTER_BINDINGS,
    HTTP_PROVIDERS,
    bind(APP_BASE_HREF).toValue('/')
  ])
  </code></pre>
  
  <p>I'm expecting all uses of <code>Http</code> to use the new content-type, but this code still has the content-type set to <code>text/plain</code></p>
  
  <pre><code>saveMaster (master) {
    return this.http
      .put(`${config.API_URL}/masters/${master._id}`, JSON.stringify(master))
      .map(res =&gt; res.json())
  }
  </code></pre>
  
  <p>I have to manually set the headers for each request to get it work correctly. Am I doing something wrong?</p>
  
  <p><strong>Note:</strong> I want to set a header option globally, not have to set it with every request type like is found in <a href="https://stackoverflow.com/questions/34464108/angular2-set-headers-for-every-request">this solution</a>.</p>