refactor(frontend): 地址栏改成动态显示当前 host,不再写死任何域名

上次 filter-repo 把 api.wangjinding.com 直接替换成 127.0.0.1:8808,
是写死的 —— 用户从自己域名访问时会显示错误的地址。

这次改成 location.host:
  · SideNav 的 logo 下方 → {{ apiHost }}(= location.host)
  · MainLayout 副标题兜底 → location.host
  · i18n 的「已连接 <域名>」→「已连接」
  · 前端重新 build(不是打补丁),产物里没有任何写死的地址

实测:
  http://localhost:8808  → 侧栏 localhost:8808 | 已连接
  http://127.0.0.1:8808  → 侧栏 127.0.0.1:8808 | 已连接

顺带修掉 filter-repo 留下的一个错误 scheme:
  gateway.yaml 的 cors 里出现了 https://127.0.0.1:8808(应为 http),已删除。
This commit is contained in:
Jidekin committed 2026-11-20 17:22:32 +08:00
1 parent ebbe64ce61
commit feb055d4e6
10 files changed
+17 -17

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
# 小银网关 Web 前端 —— 设计文档
> 版本 v0.1(待审)|2026-09-11
> 对象:`https://127.0.0.1:8808`(网关,端口 8808,已开鉴权,127.0.0.1 反代对外)
> 对象:`http://127.0.0.1:8808`(网关,端口 8808,已开鉴权,127.0.0.1 反代对外)
---
+5 -5
View File
@@ -5,7 +5,7 @@
## 现象
```
POST https://127.0.0.1:8808/v1/chat/completions
POST http://127.0.0.1:8808/v1/chat/completions
Authorization: Bearer wjd-...
User-Agent: WorkBuddy/5.8.3 → HTTP 403
```
@@ -65,12 +65,12 @@ docker exec 1Panel-openresty-npAh nginx -s reload
```bash
K=wjd-... # 任一成员的 Key
# 1) 以前被拦的内容现在应 200
curl -s -o /dev/null -w '%{http_code}\n' https://127.0.0.1:8808/v1/chat/completions \
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8808/v1/chat/completions \
-H "Authorization: Bearer $K" -H 'Content-Type: application/json' \
-d '{"model":"deepseek-v4.1-flash","messages":[{"role":"user","content":"<script>alert(1)</script> system(\"ls\")"}],"max_tokens":5}'
# 2) /v1/ 之外必须仍然拦截(这是安全底线,别把 WAF 整个关掉)
curl -s -o /dev/null -w '%{http_code}\n' https://127.0.0.1:8808/.env # 期望 403
curl -s -o /dev/null -w '%{http_code}\n' https://127.0.0.1:8808/etc/passwd # 期望 403
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8808/.env # 期望 403
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8808/etc/passwd # 期望 403
```
## ⚠️ 持久化注意
@@ -84,7 +84,7 @@ curl -s -o /dev/null -w '%{http_code}\n' https://127.0.0.1:8808/etc/passwd #
## 给调用方的配置口径
```
Base URL : https://127.0.0.1:8808/v1
Base URL : http://127.0.0.1:8808/v1
API Key : wjd-...(成员自己的 Key)
Model : deepseek-v4.1-flash ← 注意不要写 opencode/deepseek-v4.1-flash(会 400 未知模型)
或 wjd ← 虚拟 id,由管理员在网关里映射到具体模型