feat: 配置简化为同源相对路径,统一 /api/ 路由约定

配合 zTools2 路由统一到 /api/,简化环境感知配置:
- app.config.js:去掉 BASE_URL 的 dev/prod 分支,iframe 与探针一律用同源相对路径
  (/api/pdf、/api/health、/api/wb-page/{id}),默认空 baseUrl;保留 VITE_API_BASE 覆盖。
  这样无论 dev(vite proxy)还是任意部署环境(反代),同源相对路径都自动指向当前环境 zTools2,
  不再误打到 f.zikai.wang 等其它环境域名。
- vite.config.js:dev proxy 从 /api /pdf /health /static /upload /files /wb /ws 多条
  简化为单条 /api(含 ws:true,覆盖 /api/ws WebSocket)。
- deploy.sh:Apache vhost 从多条 ProxyPass 简化为单条 /api/,a2enmod 增加 proxy_wstunnel。
- docs/deployment.md:更新拓扑/模式说明,新增路由约定(所有入口在 /api/ 下,反代只需一条规则)。
- 同步更新 zPDF_package 子模块指针(其 vite proxy 亦简化为单条 /api)。
This commit is contained in:
2026-07-27 15:44:49 +08:00
parent 39f3056099
commit 304ebc9448
5 changed files with 43 additions and 85 deletions

View File

@@ -62,39 +62,13 @@ export default defineConfig({
target: 'http://localhost:8080',
changeOrigin: true,
},
// zTools2 后端同源代理:开发环境把 /api /pdf /health /static 等转发到本地 zTools2
// 使 iframe/pdf与 fetch/api/pdf/*同源命中本地服务(测试环境指向测试环境)
// 生产构建时 app.config.js 的 baseUrl 指向线上 f.zikai.wang走此代理。
// zTools2 后端同源代理:所有入口(页面/静态/探针/WS/API统一在 /api/ 下
// 一条 /api 规则即可覆盖 iframe/api/pdf与 fetch/api/pdf/*)。
// ws:true 让 /api/ws/wb/{id} 的 WebSocket 也走此代理。
// 同源相对路径与环境无关dev 命中本地 zTools2生产由反代命中当前环境 zTools2。
'/api': {
target: 'http://127.0.0.1:6867',
changeOrigin: true,
},
'/pdf': {
target: 'http://127.0.0.1:6867',
changeOrigin: true,
},
'/health': {
target: 'http://127.0.0.1:6867',
changeOrigin: true,
},
'/static': {
target: 'http://127.0.0.1:6867',
changeOrigin: true,
},
'/upload': {
target: 'http://127.0.0.1:6867',
changeOrigin: true,
},
'/files': {
target: 'http://127.0.0.1:6867',
changeOrigin: true,
},
'/wb': {
target: 'http://127.0.0.1:6867',
changeOrigin: true,
},
'/ws': {
target: 'ws://127.0.0.1:6867',
ws: true,
},
},