From 2836efc607eb5b139b6ffd08df121e26a1e8bc6d Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 9 Sep 2026 06:44:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(web):=20=E8=B0=83=E5=A4=A7=20dev=20?= =?UTF-8?q?=E5=90=8C=E6=BA=90=E4=BB=A3=E7=90=86=E8=B6=85=E6=97=B6,?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E9=95=BF=E9=80=89=E8=82=A1=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E8=A2=AB=E6=88=AA=E6=96=AD=E4=B8=BA=20500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: next dev 的 rewrites 代理默认 30s 超时(http-proxy),而全市场 同步选股实测需 ~50s; 超时后代理断开连接, 前端收到 "POST /selections → 500: Internal Server Error"。 配置 experimental.proxyTimeout=300s 后, 经前端代理的选股请求 (52.9s) 验证返回 200。 --- frontend/web/next.config.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/web/next.config.ts b/frontend/web/next.config.ts index bcc752c..81c14f1 100644 --- a/frontend/web/next.config.ts +++ b/frontend/web/next.config.ts @@ -4,6 +4,10 @@ const nextConfig: NextConfig = { reactStrictMode: true, // 局域网/远程设备访问 dev server 时,/_next/* 资源按允许来源放行(Next 15.5+) allowedDevOrigins: ["192.168.1.160", "127.0.0.1", "localhost"], + // dev server 同源代理(rewrites)默认 30s 超时(http-proxy),而选股/因子研究等 + // 同步后端接口需数十秒(全市场选股实测 ~50s),超过会被代理掐断成 500 + // ("Failed to proxy ... socket hang up")。调大至 5 分钟,避免长研究请求被截断。 + experimental: { proxyTimeout: 300_000 }, // 同源代理:页面请求 /api/* → 后端 FastAPI(默认 127.0.0.1:8000) // 使任何 IP/域名访问前端都无需 CORS 与硬编码后端地址。 // 后端地址可用环境变量 BACKEND_API_URL 覆盖(如 0.0.0.0 部署到别的机器)。