diff --git a/README.md b/README.md index a66212c..b0836c6 100644 --- a/README.md +++ b/README.md @@ -46,13 +46,13 @@ cd backend python3 -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -r requirements.txt -uvicorn app.main:app --reload --port 8000 +uvicorn app.main:app --reload --port 23568 cd frontend npm install && npm run dev ``` -开发前端:http://localhost:5173(代理 `/api` 到 8000) +开发前端:http://localhost:5173(代理 `/api` 到 23568) 生产网关本地模拟: diff --git a/backend/.env.example b/backend/.env.example index 4957f0c..aa8feeb 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -2,7 +2,7 @@ DATABASE_URL=postgresql://gradeapp:postgres@127.0.0.1:5432/student_archive SECRET_KEY=dev-secret-key-change-in-production CORS_ORIGINS=http://localhost:5173,http://localhost:23566 UPLOAD_DIR=uploads -API_PORT=8000 +API_PORT=23568 OLLAMA_BASE_URL=http://127.0.0.1:11434 OLLAMA_MODEL=qwen2.5:7b FLUCTUATION_THRESHOLD=0.08 diff --git a/docs/DEPLOY.md b/docs/DEPLOY.md index d78484b..539aac1 100644 --- a/docs/DEPLOY.md +++ b/docs/DEPLOY.md @@ -13,14 +13,14 @@ | 系统 | Ubuntu 20.04 / 22.04 / 24.04 | | 用户 | **root** | | 目录 | `/opt/secondary-school-grade-archive` | -| 端口 | **23566**(Web + API 统一入口) | +| 端口 | **23566** 对外 Web;**23568** 内部 API(仅本机) | | 反向代理 | **不包含**,请自行配置 | ### 架构 ``` 浏览器 → :23566 (PM2: grade-web, Express 静态 + /api 反代) - └──→ 127.0.0.1:8000 (PM2: grade-api, Uvicorn) + └──→ 127.0.0.1:23568 (PM2: grade-api, Uvicorn) └──→ PostgreSQL (本机) └──→ uploads/ └──→ Ollama (本机可选, :11434) @@ -72,7 +72,8 @@ bash deploy/install.sh | 变量 | 默认 | 说明 | |------|------|------| | `WEB_PORT` | 23566 | 对外 Web 端口 | -| `API_PORT` | 8000 | 内部 API 端口 | +| `API_PORT` | 23568 | 内部 API 端口(仅本机,勿与 8000 等常用端口冲突) | +| `API_TARGET` | `http://127.0.0.1:23568` | Web 网关转发目标 | | `DATABASE_URL` | 自动生成 | PostgreSQL 连接 | | `SECRET_KEY` | 自动生成 | JWT 密钥 | | `UPLOAD_DIR` | `.../uploads` | 错题图片目录 | diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 1406734..5c81bba 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -7,7 +7,7 @@ export default defineConfig({ port: 5173, proxy: { '/api': { - target: 'http://localhost:8000', + target: 'http://localhost:23568', changeOrigin: true, }, },