我可以通过添加以下内容来设置请求 header 以公开 Content-Disposition:
“访问控制公开 header ”:“内容处置”
我可以看到响应,但响应对象不包括 Content-Disposition。
Click here for detail screenshot
有什么办法可以访问该值?
axios 版本:0.15.2
环境:node v6.9.4,chrome 54,windows 7
最佳答案
就我而言,我必须在服务器端启用与 CORS 相关的功能:
Access-Control-Expose-Headers: Content-Disposition
这允许浏览器端的 javascript 读取此 header 。
如果是服务器端的 node.js + express + cors,它可能看起来像这样:
app.use(cors({
origin: 'http://localhost:8080',
credentials: true,
exposedHeaders: ['Content-Disposition']
}))
所以我可以在 Axios 返回的标题中看到“内容处置”。
关于cors - axios 暴露响应头 : Content-Disposition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43912862/