“Access-Control-Expose-Headers”:首先得注意是"Access-Control-Expose-Headers"进行跨域请求时响应头部中的一个字段,对于同域请求,响应头部是没有这个字段的。这个字段中列举的 header 字段就是服务器允许暴露给客户端访问的字段。
在使用CORS解决跨域的请求中,默认只能取到
Content-Language
Content-Type
Expires
Last-Modified
Pragma
五个reponse header 值。
因此在服务器端需要设置:
Access-Control-Expose-Headers : sessionID , key1 , key2, token
前端就可以获取到了
axios.interceptors.response.use(function (res) {
console.log(res, 'res------------获取的数据')
}