网上找了好多资料,都不可用,这个是自测试可用的nginx 跨域示例
location /haos/ {
proxy_pass http://localhost:8001/haos/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header Access-Control-Allow-Methods *;
add_header Access-Control-Max-Age 3600;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Origin $http_origin;
add_header Access-Control-Allow-Headers *;
if ($request_method = OPTIONS){
return 200;
}
}