fix(#188): 推理 API 路径规范化,消除双 /v1 前缀对 nginx rewrite 的隐式依赖
问题:infer.ts BASE_URL=/v1,fetchModels/chatCompletion 再拼 /v1/* 导致 /v1/v1 双前缀,当前仅靠 nginx 对 /v1/ rewrite 去前缀巧合耦合才通。 修复(前后端+部署一起改): 1. nginx-fba.conf:新增 location /v1/,proxy_pass http://127.0.0.1:30800/ (带末尾 /,不去前缀直接透传),消除对 rewrite 的隐式依赖。 2. infer.ts:BASE_URL 改为空串,调用方统一写 /v1/models、 /v1/chat/completions、/v1/health(fetchHealth 原误用 /health 已修正)。 3. cockpit/index.vue:健康检查改走 infer.ts 的 fetchHealth 封装, 不再裸 fetch('/v1/health'),路径口径统一。 4. ask() latencyMs 由硬编码 0 改为 performance.now() 实测耗时。 5. README 补充推理通道路径约定说明。 验收:浏览器 Network 确认 /v1/models、/v1/chat/completions、 /v1/health 均 200 且无 /v1/v1 请求。(本环境无 pnpm,构建验证转 bot_qa)
This commit is contained in:
@@ -138,9 +138,15 @@ docker exec -it fba_postgres psql -U postgres -d fba # 进数据库
|
||||
│ · 6 模块 → views/iaop/*(cockpit/chat/studio/admin)
|
||||
│ · 推理通道 /v1/ → 127.0.0.1:30800(推理服务,独立于 /fba)
|
||||
├── /fba/ → 127.0.0.1:8001 fba_server(认证/RBAC/系统管理)
|
||||
└── /v1/ → 127.0.0.1:30800 推理服务(iAOP LLM 网关)
|
||||
└── /v1/ → 127.0.0.1:30800 推理服务(iAOP LLM 网关,**不去前缀直接透传**)
|
||||
```
|
||||
|
||||
### 推理通道路径约定(issue #188)
|
||||
- 推理服务真实路径即 `:30800/v1/*`(`/v1/models`、`/v1/chat/completions`、`/v1/health`)。
|
||||
- nginx 反代 `/v1/` 用 `proxy_pass http://127.0.0.1:30800/`(带末尾 `/`,**不去前缀**,直接透传到后端的 `/v1/...`)。
|
||||
- 前端 `api/iaop/infer.ts` 的 `BASE_URL` 为空串,调用方统一写 `/v1/models`、`/v1/chat/completions`、`/v1/health`,**不再出现 `/v1/v1` 双前缀**,也不依赖 nginx rewrite 去前缀的巧合耦合。
|
||||
- nginx location 片段见 `deploy/fba/nginx-fba.conf`。
|
||||
|
||||
### 组件落点
|
||||
- 受控源码:`fba-ui-src/`(fastapi-best-architecture-ui 工程,apps/web-antdv-next)
|
||||
- 构建流水线:`build-ui.sh`(pnpm install → build → artifacts/fba-ui-dist.tar.gz)
|
||||
|
||||
Reference in New Issue
Block a user