Standardize SurClaw ports away from defaults

- Change the API default listen port from 3000 to 3100 and include the Docker frontend origin in default CORS.

- Point Vite's default API proxy, Docker API container port, and Nginx upstream to 3100.

- Keep Docker host ports on 4002 for web, 3002 for API, and 5433 for PostgreSQL.

- Update environment examples and documentation to remove stale localhost:3000 guidance.
This commit is contained in:
2026-05-02 02:17:07 +08:00
parent 750cf4129d
commit 7c6449b7bd
11 changed files with 25 additions and 24 deletions

View File

@@ -51,7 +51,7 @@ http://localhost:3001
```
`npm run dev` 实际使用 `vite --port=3001 --host=0.0.0.0`,局域网内也可以通过机器 IP 访问。
开发模式下 Vite 会把 `/api` 代理到 `VITE_API_PROXY_TARGET`,默认是 `http://localhost:3000`。如果只启动 Docker Compose 中的 API再用本机 Vite 前端调试,可把该变量改成 `http://localhost:3002`
开发模式下 Vite 会把 `/api` 代理到 `VITE_API_PROXY_TARGET`,默认是 `http://localhost:3100`。如果只启动 Docker Compose 中的 API再用本机 Vite 前端调试,可把该变量改成 `http://localhost:3002`
后端 API 开发服务默认监听:
@@ -62,7 +62,7 @@ npm run server:dev
```
```text
http://localhost:3000/api/health
http://localhost:3100/api/health
```
如果需要真实数据库,先启动 PostgreSQL 并配置 `DATABASE_URL`,再执行:
@@ -87,7 +87,7 @@ npm run prisma:seed
```bash
npm run dev # 启动开发服务器,端口 3001
npm run server:dev # 编译并启动 NestJS API默认端口 3000
npm run server:dev # 编译并启动 NestJS API默认端口 3100
npm run server:build # 构建后端 TypeScript
npm run lint # TypeScript 类型检查
npm run test # Vitest 测试
@@ -118,13 +118,13 @@ cp .env.example .env.local
当前环境变量:
- `API_PORT`NestJS API 监听端口,本地直接运行默认 `3000`Docker Compose 暴露到宿主机的默认端口是 `3002`
- `API_PORT`NestJS API 监听端口,本地直接运行默认 `3100`Docker Compose 暴露到宿主机的默认端口是 `3002`
- `CORS_ORIGIN`:允许携带 Cookie 访问 API 的前端来源。
- `DATABASE_URL`PostgreSQL 连接串。Docker Compose 暴露到宿主机的默认端口是 `5433`,容器内部仍使用 `db:5432`
- `SESSION_SECRET`:后端 Session Cookie 签名密钥,生产环境必须替换。
- `SESSION_COOKIE_SECURE`:是否只通过 HTTPS 发送 Session Cookie。本地 HTTP/Compose 默认 `false`
- `FILE_STORAGE_DIR`后端文件存储目录。Docker Compose 默认挂载到 `/app/uploads`
- `VITE_API_PROXY_TARGET`Vite 开发服务器的 `/api` 代理目标。直接运行 `npm run server:dev` 时用 `http://localhost:3000`;连接 Docker Compose API 时用 `http://localhost:3002`
- `VITE_API_PROXY_TARGET`Vite 开发服务器的 `/api` 代理目标。直接运行 `npm run server:dev` 时用 `http://localhost:3100`;连接 Docker Compose API 时用 `http://localhost:3002`
- `VITE_ENABLE_LOCAL_FALLBACK`:是否允许生产构建继续使用浏览器本地兼容回退。开发模式默认启用,生产默认关闭。
注意:当前 AI/语音密钥由后端设置读取并在代理中使用,普通用户读取设置时不返回真实密钥。视频和关键帧文件已优先写入后端,报告内媒体引用通过 `ReportMedia` 关系表保存。