title: Get response custom headers for cross-origin request
body: <p>I have an Angular2/4 application with a get request that has a response header with a key of 'X-Auth-Key'. When I call response.header I get the default headers and then I call response.headers.get('X-Auth-Token') I get null. Below is my code and a screenshot of the request from the Chrome Console (var url is defined elsewhere).</p>
  
  <pre><code>    getToken(id: string, password: string): Observable&lt;User&gt; {
      let headers = new Headers({ 'X-Auth-User': id, 'X-Auth-Key': password });
      return this.http
          .get(url + 'auth', { headers: headers })
          .map(response =&gt; {
              let user: User = response.json() as User;
  
              // store user details and jwt token in local storage to keep user logged in between page refreshes
              localStorage.setItem('currentUser', JSON.stringify({ user: user, token: response.headers.get('X-Auth-Token') }));
  
              return user;
          })
     }// Get authorization token
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/MspJK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MspJK.png" alt="enter image description here"></a></p>
  
  <p>I'm not sure what I am doing wrong, but I appreciate any help </p>
  
  <p><strong>Thanks!</strong></p>