https://blog.csdn.net/adsadadaddadasda/article/details/79564683

 

 

最近用vue.js+axios开发单页面应用时,需要把自定义信息(token,uid)放到response  header中返回,如下

然后在客户端获取在服务器端自定义的header信息:

但是我得到的结果里却没有我自定义的值

在浏览器网络菜单里,去可以看到所有的response  header信息,包含服务器端自定义的。

原因:

在使用CORS方式跨域时,浏览器只会返回以下默认头部header:

  • response  header
  • Content-Language
  • Content-Type
  • Expires
  • Last-Modified
  • Pragma

如果你想在客户端app中获取自定义的header信息,需要在服务器端header中添加Access-Control-Expose-Headers:

发表评论

电子邮件地址不会被公开。