2026-04-28 19:48:40 +08:00
|
|
|
server {
|
|
|
|
|
listen 80;
|
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
|
index index.html;
|
|
|
|
|
|
2026-05-04 18:00:58 +08:00
|
|
|
# 👇 跨域配置开始
|
|
|
|
|
add_header Access-Control-Allow-Origin * always;
|
|
|
|
|
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, PUT, DELETE' always;
|
|
|
|
|
add_header Access-Control-Allow-Headers '*, Origin, X-Requested-With, Content-Type, Accept, Authorization, X-Token' always;
|
|
|
|
|
add_header Access-Control-Allow-Credentials 'true' always;
|
|
|
|
|
|
|
|
|
|
# 处理预检 OPTIONS 请求
|
|
|
|
|
if ($request_method = 'OPTIONS') {
|
|
|
|
|
return 204;
|
|
|
|
|
}
|
|
|
|
|
# 👆 跨域配置结束
|
|
|
|
|
|
2026-04-28 19:48:40 +08:00
|
|
|
location / {
|
|
|
|
|
try_files $uri $uri/ /index.html;
|
|
|
|
|
}
|
|
|
|
|
}
|