File size: 1,124 Bytes
1d2d958 417db18 ee3b83b 417db18 1d2d958 ee3b83b 1d2d958 ee3b83b 1d2d958 ee3b83b 1d2d958 ee3b83b 1d2d958 ee3b83b 1d2d958 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | server {
listen 7860;
server_name localhost;
# 设置较长的超时时间,防止大模型生成时断连
proxy_read_timeout 300s;
proxy_connect_timeout 300s;
# 后端 API 转发 (保持原样)
location /api {
proxy_pass http://127.0.0.1:5001;
# 后端通常需要真实的 Host 信息,所以这里保持 $host
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# 前端转发 (关键修改)
location / {
proxy_pass http://127.0.0.1:3000;
# [修复] 强制将 Host 头设置为 localhost
# 这样 Vite 就会认为请求来自本地,从而通过 allowedHosts 检查
proxy_set_header Host "localhost";
# WebSocket 支持 (用于热更新和实时通信)
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# 传递真实 IP
proxy_set_header X-Real-IP $remote_addr;
}
} |