配置如下
# 允许跨域请求add_header Access-Control-Allow-Origin *;# 允许带身份验证信息的跨域请求add_header Access-Control-Allow-Credentials true;# 允许的请求方法add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';# 允许的请求头add_header Access-Control-Allow-Headers 'Token,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
但是浏览器还是报错跨域了。
点开响应头,发现有重复的响应头。
删除重复响应头就可以了
#先删除响应头 proxy_hide_header Access-Control-Allow-Origin;proxy_hide_header Access-Control-Allow-Methods;proxy_hide_header Access-Control-Allow-Headers;#重新添加响应头,跨域配置add_header Access-Control-Allow-Origin *;add_header Access-Control-Allow-Methods 'GET,POST,OPTIONS';add_header Access-Control-Allow-Headers *;