fix(ops): allow local Admin LAN access (#304)

This commit is contained in:
QiuSW
2026-09-17 17:02:35 +08:00
parent c2426e2671
commit 9194fd664f
3 changed files with 28 additions and 7 deletions
+11 -2
View File
@@ -2,8 +2,8 @@
generated: true (请先修改 Gitea Wiki,禁止直接编辑本文件)
wiki_page: Deployment-and-Operations
wiki_url: https://git.ilapage.cn/OPC/goauto/wiki/Deployment-and-Operations.-
wiki_revision: 933eaf6cc02fed843a6898269fdb5f6848ac2a8a
synchronized_at: 2026-09-10T01:42:05Z
wiki_revision: a8da51a554b9c43da4b72104d707d3c72c5cd534
synchronized_at: 2026-09-17T08:57:51Z
<!-- gitea-wiki-mirror:end -->
# 部署与运维
@@ -104,3 +104,12 @@ Provider 故障日志只允许记录调用关联 ID、操作类型、耗时、
- 建议API写超时至少为 2T+30 秒,且仍满足原最低620秒;代理读/发送超时需留足对应窗口。T=60/180时原620秒足够容纳应用预算;T=600时至少需要1230秒API写超时及适当更长的代理窗口。不得仅设置较大的AI超时却忽略传输层更早截断。
- 上述是发布核对要求,不是本单已修改/验证线上代理的结论。超大T带来长连接占用,不能用关闭超时来代替正确预算。新增失败回读不代表必须延长任何线上请求。
- 必须配套发布 Server/Web;仅上新版Web连接旧Server时,因缺失派生预算会提示等待时间不可用并停止匹配。原Android不需升级。
## 本地 Supervisor 与局域网访问
本机开发/联调环境由 `D:\supervisor\programs\goauto.conf` 分别启动 GoAuto API 与 Admin Web;实例配置只负责调用项目脚本,端口读取 `D:\OPC\goauto\config.yaml`。
- API 由 `scripts/start-server.ps1` 启动并监听所有网卡的 `ports.server`。
- Admin Web 由 `scripts/start-web.ps1` 启动,监听 `0.0.0.0` 的 `ports.web`,因此同一局域网设备可通过 `http://<本机局域网IP>:<web端口>/` 访问。
- 浏览器使用同源相对 API;Vite 将 `/api` 与 `/static` 代理到本机 `127.0.0.1:<server端口>`,避免局域网客户端错误访问自身的 `127.0.0.1`。
- 修改脚本或配置后,只需重启 Supervisor 的 `goauto-admin-ui`;API 未变化时无需重启 `goauto-admin-api`。若局域网仍无法连接,检查 Windows 防火墙是否允许 `ports.web` 的 TCP 入站。
+7 -3
View File
@@ -168,18 +168,22 @@ try {
}
}
$env:VUE_APP_BASE_API = "http://127.0.0.1:$($ports.Server)"
Write-Host "Starting GoAuto web UI at http://127.0.0.1:$($ports.Web)" -ForegroundColor Green
# Keep browser requests same-origin. Vite proxies API/static requests to the
# local backend, so a LAN client never tries to call its own 127.0.0.1.
$env:VUE_APP_BASE_API = ""
$env:VITE_DEV_PROXY_TARGET = "http://127.0.0.1:$($ports.Server)"
Write-Host "Starting GoAuto web UI at http://0.0.0.0:$($ports.Web)" -ForegroundColor Green
$viteCli = Join-Path $webDirectory "node_modules\vite\bin\vite.js"
if (-not (Test-Path -LiteralPath $viteCli -PathType Leaf)) {
throw "Vite was not found after dependency installation: $viteCli"
}
& $nodePath $viteCli --host 127.0.0.1 --port $ports.Web --strictPort
& $nodePath $viteCli --host 0.0.0.0 --port $ports.Web --strictPort
if ($LASTEXITCODE -ne 0) {
throw "Frontend exited with code $LASTEXITCODE."
}
}
finally {
Remove-Item Env:VUE_APP_BASE_API -ErrorAction SilentlyContinue
Remove-Item Env:VITE_DEV_PROXY_TARGET -ErrorAction SilentlyContinue
Pop-Location
}
+10 -2
View File
@@ -12,6 +12,11 @@ export default defineConfig(({ mode }) => {
// 颜色图片等上传文件的地址是相对路径 /static/...,浏览器会按页面来源解析。
// 开发服务器与后端不同源,必须代理到后端,否则图片 404 显示“加载失败”。
const backendOrigin = process.env.VUE_APP_BASE_API || env.VUE_APP_BASE_API || ''
const devProxyTarget = process.env.VITE_DEV_PROXY_TARGET || env.VITE_DEV_PROXY_TARGET || backendOrigin
// start-web.ps1 supplies a dedicated proxy target for LAN development.
// In that mode the browser must always use relative URLs, even though the
// legacy .env.development still contains a localhost API origin.
const browserBaseApi = devProxyTarget ? '' : backendOrigin
return {
base: '/',
@@ -46,14 +51,17 @@ export default defineConfig(({ mode }) => {
// 业务代码沿用 process.env.VUE_APP_* 写法,此处做等价注入
define: {
'process.env.VUE_APP_BASE_API': JSON.stringify(process.env.VUE_APP_BASE_API || env.VUE_APP_BASE_API || ''),
'process.env.VUE_APP_BASE_API': JSON.stringify(browserBaseApi),
'process.env.NODE_ENV': JSON.stringify(mode === 'development' ? 'development' : 'production')
},
server: {
port: 9527,
open: false,
proxy: backendOrigin ? { '/static': { target: backendOrigin, changeOrigin: true }} : undefined
proxy: devProxyTarget ? {
'/api': { target: devProxyTarget, changeOrigin: true },
'/static': { target: devProxyTarget, changeOrigin: true }
} : undefined
},
css: {