vault backup: 2026-05-18 21:32:25

This commit is contained in:
hhs
2026-05-18 21:32:25 +08:00
parent 57346735d3
commit af4f967ec9
+6 -5
View File
@@ -169,9 +169,8 @@ server {
try_files $uri $uri/ /index.html;
}
# --- API 反代 + CORS ---
location /api/ {
# 处理预检请求
# --- Location 1: OPTIONS 预检请求(直接返回,不通后端)---
location ~ ^/api/.*$ {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '$http_origin';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
@@ -179,10 +178,12 @@ server {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204; # 直接结束预检,不走后端
return 204;
}
}
# 真实请求,注入响应头
# --- Location 2: 真实请求(反向代理 + CORS 头)---
location /api/ {
add_header 'Access-Control-Allow-Origin' '$http_origin' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';