服务器是 nginx,配置了跨域,代码如下
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS,PUT';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
if ($request_method = 'OPTIONS') {
return 204;
}
js 获取 response 的头部打印出来只有
cache-control: "private, must-revalidate"
content-type: "application/json"
浏览器里面可以看到所有的响应头信息,js 想获取其他的头部信息,请问下哪里没有配置对呢? 问题和这篇文章一样 https://segmentfault.com/a/1190000009125333 ,但是还是解决不了。