fix: expose server on host network interface

This commit is contained in:
liyy 2026-08-28 09:24:02 +08:00
parent ca9ce54d13
commit 35092017f1
2 changed files with 3 additions and 2 deletions

View File

@ -8,13 +8,14 @@
- `pnpm typecheck`通过server、client
- `pnpm build`通过server、client
- `GET /health`:通过,返回 `{"status":"ok","service":"gwy-server"}`
- 宿主机 IP `172.16.34.66:3000/health`:通过;后端已绑定 `0.0.0.0`,可从局域网地址访问。
- 前端开发服务可启动Vite 返回 HTTP 200
## 浏览器检查
- 已启动 Vite 与 Fastify 服务。
- 按计划尝试使用内置浏览器打开前端并获取 DOM/截图。
- 当前运行环境的内置浏览器无法访问本地开发端口,返回 `ERR_CONNECTION_REFUSED`;终端网络环境可以访问同一端口。
- 当前运行环境的内置浏览器尝试访问 `172.16.34.66:5173` 时仍然连接超时;终端网络环境可以访问同一端口。
- 因此本项的浏览器实际操作和原型截图对比暂记为“环境阻塞”,不宣称通过;待浏览器可访问本地服务后补检。
## 当前结论

View File

@ -4,4 +4,4 @@ import cors from '@fastify/cors'
const app = Fastify({ logger: true })
await app.register(cors, { origin: true })
app.get('/health', async () => ({ status: 'ok', service: 'gwy-server' }))
app.listen({ port: Number(process.env.PORT ?? 3000), host: '127.0.0.1' })
app.listen({ port: Number(process.env.PORT ?? 3000), host: process.env.HOST ?? '0.0.0.0' })