How to get all headers from Angular 2 answer?

Response in Chrome Dev Tools

The response headers that I see in Chrome Dev tools do not match those that Angular 2 displays in the Chrome console.

Content Type Only Displayed Up

After the command is executed, only the Content-Type header appears:

this.http.get(tempUrl).map(res=>{ console.log("csrf received"); console.log(res); }) 
+4
source share
1 answer

Only a specific list of "safe" headers is provided by default (for Javascript). This is for security reasons. This list is as follows

  • Cache control
  • Content language
  • content type
  • Expires
  • Last change
  • Pragma

To set other headers, the server must send an Access-Control-Expose-Headers control header, listing all the headers that it wants to provide.

 Access-Control-Expose-Headers: Content-Length, X-CSRF-Token 
+8
source

Source: https://habr.com/ru/post/1015083/


All Articles