diff --git a/nginx-extra.conf b/nginx-extra.conf new file mode 100644 index 0000000..3ea98b1 --- /dev/null +++ b/nginx-extra.conf @@ -0,0 +1,16 @@ +server { + ## ... + location ~ [^/]\.php(/|$) { + # 添加CORS头部 + add_header 'Access-Control-Allow-Origin' '*' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always; + add_header 'Access-Control-Max-Age' 1728000 always; + # 处理预检请求 + if ($request_method = 'OPTIONS' ) { + return 204; + } + ## ... + } + ## ... +} \ No newline at end of file