diff --git a/.env.example b/.env.example index ae6b078..1cb8a8b 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,6 @@ -PORT=3001 +PORT=3010 NODE_ENV=development -CORS_ORIGIN=http://localhost:5173 +CORS_ORIGIN=http://localhost:5180 # 正式环境必须填写;本地 SQLite 模式可暂时留空。 DATABASE_URL=postgresql://delivery_desk:local_delivery_desk@127.0.0.1:5432/delivery_desk diff --git a/Dockerfile b/Dockerfile index 8c79545..585c084 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,5 +16,5 @@ COPY --from=build /app/api ./api COPY --from=build /app/shared ./shared COPY --from=build /app/db ./db COPY --from=build /app/dist ./dist -EXPOSE 3001 +EXPOSE 3010 CMD ["pnpm", "server:prod"] diff --git a/README.md b/README.md index 0c4b434..84766d3 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,9 @@ pnpm install pnpm dev ``` -- 前端:`http://localhost:5173` -- API:`http://localhost:3001` -- 健康检查:`http://localhost:3001/api/health` +- 前端:`http://localhost:5180` +- API:`http://localhost:3010` +- 健康检查:`http://localhost:3010/api/health` 未配置 `DATABASE_URL` 时使用 `data/app.db`;本地图片保存在 `uploads/`。这两个目录包含运行数据、账号信息或用户文件,已排除在 Git 之外。 @@ -75,7 +75,7 @@ pnpm db:postgres:migrate -- --replace docker compose up -d --build ``` -应用通过 `http://服务器地址:3001` 同时提供前端与 API。公网环境应在前面配置 HTTPS 反向代理;生产 Cookie 会自动添加 `Secure`。 +应用通过 `http://服务器地址:3010` 同时提供前端与 API。公网环境应在前面配置 HTTPS 反向代理;生产 Cookie 会自动添加 `Secure`。 ## 文档与检查 diff --git a/api/server.ts b/api/server.ts index bcef8e1..0eac62e 100644 --- a/api/server.ts +++ b/api/server.ts @@ -7,7 +7,7 @@ import { closeDatabase } from './database.js'; /** * start server with port */ -const PORT = process.env.PORT || 3001; +const PORT = process.env.PORT || 3010; const server = app.listen(PORT, () => { console.log(`Server ready on port ${PORT}`); diff --git a/compose.yaml b/compose.yaml index a5859f5..a8393d4 100644 --- a/compose.yaml +++ b/compose.yaml @@ -7,7 +7,7 @@ services: condition: service_healthy environment: NODE_ENV: production - PORT: 3001 + PORT: 3010 DATABASE_URL: postgresql://delivery_desk:${POSTGRES_PASSWORD}@postgres:5432/delivery_desk PGSSL: disable COS_CONFIG_ENCRYPTION_KEY: ${COS_CONFIG_ENCRYPTION_KEY:?COS_CONFIG_ENCRYPTION_KEY is required} @@ -15,9 +15,9 @@ services: INITIAL_ADMIN_USERNAME: ${INITIAL_ADMIN_USERNAME:-admin} INITIAL_ADMIN_DISPLAY_NAME: ${INITIAL_ADMIN_DISPLAY_NAME:-平台管理员} ports: - - "3001:3001" + - "3010:3010" healthcheck: - test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:3001/api/health').then(r=>{if(!r.ok)process.exit(1)})"] + test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:3010/api/health').then(r=>{if(!r.ok)process.exit(1)})"] interval: 10s timeout: 5s retries: 10 diff --git a/docs/integration-guide.md b/docs/integration-guide.md index cda26d7..8e447c7 100644 --- a/docs/integration-guide.md +++ b/docs/integration-guide.md @@ -35,7 +35,7 @@ API Key 明文只在创建时返回一次,数据库仅保存 SHA-256 哈希。 平台级 API Key 可以指定目标运营组。项目级 Key 不能创建项目。 ```bash -curl -X POST http://localhost:3001/api/projects \ +curl -X POST http://localhost:3010/api/projects \ -H "Authorization: Bearer $DELIVERY_DESK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"name":"7 月内容计划","slug":"july-content","groupId":1,"client_description":"客户可见说明"}' @@ -46,7 +46,7 @@ curl -X POST http://localhost:3001/api/projects \ ## 创建作品交付集 ```bash -curl -X POST http://localhost:3001/api/projects/1/collections \ +curl -X POST http://localhost:3010/api/projects/1/collections \ -H "Authorization: Bearer $DELIVERY_DESK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"name":"2026 年 7 月交付","client_description":"本月交付内容"}' @@ -57,7 +57,7 @@ curl -X POST http://localhost:3001/api/projects/1/collections \ 作品上传使用 `multipart/form-data`,至少一张、最多 30 张图片,单图最大 20 MB。图片数组顺序就是初始展示顺序,第一张为封面。 ```bash -curl -X POST http://localhost:3001/api/notes \ +curl -X POST http://localhost:3010/api/notes \ -H "Authorization: Bearer $DELIVERY_DESK_API_KEY" \ -F "collectionId=1" \ -F "title=作品标题" \ @@ -72,7 +72,7 @@ curl -X POST http://localhost:3001/api/notes \ ## 创建新版本 ```bash -curl -X POST http://localhost:3001/api/notes/12/versions \ +curl -X POST http://localhost:3010/api/notes/12/versions \ -H "Authorization: Bearer $DELIVERY_DESK_API_KEY" \ -F "title=修改后的标题" \ -F "description=修改后的正文" \ @@ -91,4 +91,3 @@ curl -X POST http://localhost:3001/api/notes/12/versions \ ``` 常见状态码:`400` 输入无效、`401` 未认证、`403` 越权、`404` 资源不存在、`409` 唯一性或状态冲突、`500` 服务端错误。 - diff --git a/docs/operator-runbook.md b/docs/operator-runbook.md index df80719..29716f0 100644 --- a/docs/operator-runbook.md +++ b/docs/operator-runbook.md @@ -5,7 +5,7 @@ | 变量 | 必需 | 说明 | |---|---|---| | `NODE_ENV` | 是 | 正式环境设为 `production` | -| `PORT` | 否 | API 与生产静态站端口,默认 `3001` | +| `PORT` | 否 | API 与生产静态站端口,默认 `3010` | | `DATABASE_URL` | 正式环境 | PostgreSQL 连接串;缺省时使用 SQLite | | `PGSSL` | 否 | 内网 PostgreSQL 可设为 `disable` | | `PG_POOL_MAX` | 否 | 连接池上限,默认 `10` | @@ -31,7 +31,7 @@ docker compose up -d --build ## 冒烟检查 ```bash -curl http://127.0.0.1:3001/api/health +curl http://127.0.0.1:3010/api/health docker compose ps docker compose logs --tail=100 app ``` @@ -67,4 +67,3 @@ pnpm test:postgres-runtime ``` 正式切换前还应验证:管理员首次改密、客户访问门禁、COS 上传、客户批注与验收、数据库备份及 HTTPS Cookie。 - diff --git a/vite.config.ts b/vite.config.ts index 00a759b..6051470 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -15,9 +15,11 @@ export default defineConfig({ tsconfigPaths(), ], server: { + port: 5180, + strictPort: true, proxy: { '/api': { - target: 'http://localhost:3001', + target: 'http://localhost:3010', changeOrigin: true, secure: false, configure: (proxy) => { @@ -33,7 +35,7 @@ export default defineConfig({ }, }, '/uploads': { - target: 'http://localhost:3001', + target: 'http://localhost:3010', changeOrigin: true, secure: false, }