Caleb0 2019-12-23
location / {
add_header ‘Access-Control-Allow-Origin‘ $http_origin;
add_header ‘Access-Control-Allow-Credentials‘ ‘true‘;
add_header ‘Access-Control-Allow-Methods‘ ‘GET, POST, OPTIONS‘;
add_header ‘Access-Control-Allow-Headers‘ ‘DNT,web-token,app-token,Authorization,Accept,Origin,Keep-Alive,User-Agent,X-Mx-ReqToken,X-Data-Type,X-Auth-Token,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range‘;
add_header ‘Access-Control-Expose-Headers‘ ‘Content-Length,Content-Range‘;
if ($request_method = ‘OPTIONS‘) {
add_header ‘Access-Control-Max-Age‘ 1728000;
add_header ‘Content-Type‘ ‘text/plain; charset=utf-8‘;
add_header ‘Content-Length‘ 0;
return 204;
}
看上面错误提示,contains multiple values "*" 意思就是设置了2次跨域,我们这边是我在nginx里面设置了跨域,开发在程序里面也设置了跨域处理,但是只有一个是允许的,移除其中的任意一个就好了。如果服务器设置了允许跨域,使用Nginx代理里面就不需要设置跨域了。