server {
listen 81;
server_name 域名;
index index.jsp index.html index.html index.shtml;
location / {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
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;
}
proxy_pass 后端地址;
}
}
nginx轻松解决跨域问题
最新推荐文章于 2024-05-09 01:22:48 发布