Files
qlib/frontend/web/.env.local.example
Simon b78852f01b fix: 前端同源代理 /api → 后端(任意 IP 访问不再 NetworkError)+ SQLite 写锁等待
- 根因①:页面硬编码 http://127.0.0.1:8000/api,从 192.168.1.160:3000 访问时浏览器请求自身/跨域失败
- 根因②(500):全市场数据同步(长写事务)持有 SQLite 锁导致读接口 database is locked
- 前端:next.config.ts rewrites /api/* → http://127.0.0.1:8000/api(BACKEND_API_URL 可覆盖);
  lib/api.ts 默认相对 /api 同源(NEXT_PUBLIC_API_BASE 保留为直连覆盖项);.env.local.example 说明两种方式
- 后端:CORS 开发期 allow_origins=["*"](无凭据,上线前收紧);SQLite engine busy_timeout=30s
- USAGE FAQ 同步;验证:192.168.1.160:3000/api/health 与 /api/factors 经代理 200,CORS 头 access-control-allow-origin: *
2026-09-06 19:00:49 +08:00

10 lines
594 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 前端环境示例(复制为 .env.local 使用)
# 默认同源代理:前端 /api/* → 后端(next.config.ts rewrites,默认 http://127.0.0.1:8000)。
# 以下两种情况需要配置:
# 1) 后端跑在别的机器/端口:给 next dev/start 进程设 BACKEND_API_URL
# (注意这是 Next 服务端代理变量,不属于 NEXT_PUBLIC_*)
# BACKEND_API_URL=http://192.168.1.160:8000
# 2) 不经过 Next 代理、让浏览器直连后端:设置 NEXT_PUBLIC_API_BASE(含 /api,浏览器可访问的地址)
# NEXT_PUBLIC_API_BASE=http://192.168.1.160:8000/api