[英]How to get all the headers from an Angular 2 response?
The response headers I see in Chrome Dev tools don't match the ones that Angular 2 is showing in the Chrome console. 我在Chrome开发工具中看到的响应标头与Angular 2在Chrome控制台中显示的响应标头不匹配。
Only the Content-Type header is showing up after having executed: 执行后只显示Content-Type标题:
this.http.get(tempUrl).map(res=>{
console.log("csrf received");
console.log(res);
})
Only a certain list of "safe" headers are exposed by default (to Javascript). 默认情况下(Javascript)只显示某个“安全”标题列表。 This is for security reasons. 这是出于安全原因。 This list is as follows 该清单如下
In order to expose other headers, the server should send the access control header Access-Control-Expose-Headers
, listing all the headers it wants to expose. 为了公开其他标头,服务器应该发送访问控制标头Access-Control-Expose-Headers
,列出它想要公开的所有标头。
Access-Control-Expose-Headers: Content-Length, X-CSRF-Token
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.