server { listen 8088; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; add_header 'Access-Control-Allow-Methods' 'POST, GET, OPTIONS'; add_header 'Access-Control-Allow-Headers' '*'; add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Credentials' 'true' ; #是否允许浏览器后续请求携带认证信息(cookies),该值只能是true,如果服务器不要浏览器发送Cookie,删除该字段即可。 #后端代理 location /api/ { if ($request_method = 'OPTIONS') { return 204; } proxy_pass http://101.32.253.94:8080; } #前端代理 location / { # OPTIONS 直接返回204 if ($request_method = 'OPTIONS') { return 204; } proxy_pass http://localhost:3440; } }
标签:Control,跨域,header,Access,nginx,add,Allow,允许,OPTIONS From: https://www.cnblogs.com/boye169/p/17805968.html