/usr/local/nginx/conf/cors.conf
add_header 'Access-Control-Allow-Credentials' "true" always; add_header 'Access-Control-Allow-Origin' '$http_origin' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; 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,Content-Disposition' always; add_header 'Access-Control-Expose-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Content-Disposition' always; add_header 'Access-Control-Max-Age' 1728000 always; if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Credentials' "true" always; add_header 'Access-Control-Allow-Origin' '$http_origin' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; 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,Content-Disposition' always; add_header 'Access-Control-Expose-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Content-Disposition' always; add_header 'Access-Control-Max-Age' 1728000 always; #add_header 'Content-Length' 0; add_header 'Content-Type' 'text/plain; charset=utf-8'; return 200; }
然后在需要的地方添加
location / { include cors.conf }
目前尚无回复