Compare commits

...

2 Commits

Author SHA1 Message Date
dekun a3d4875bde Standardize API port 23568 and web port 23566 across docs and dev config.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 13:07:46 +08:00
dekun 2a5fb5f469 Fix API port conflict default 23568, bcrypt registration, clearer login errors.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 13:04:59 +08:00
8 changed files with 13 additions and 12 deletions
+2 -2
View File
@@ -2,8 +2,8 @@
# 部署目录默认:/opt/secondary-school-grade-archive # 部署目录默认:/opt/secondary-school-grade-archive
WEB_PORT=23566 WEB_PORT=23566
API_PORT=8000 API_PORT=23568
API_TARGET=http://127.0.0.1:8000 API_TARGET=http://127.0.0.1:23568
SECRET_KEY=请替换为随机字符串 SECRET_KEY=请替换为随机字符串
POSTGRES_USER=gradeapp POSTGRES_USER=gradeapp
+2 -2
View File
@@ -46,13 +46,13 @@ cd backend
python3 -m venv venv python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000 uvicorn app.main:app --reload --port 23568
cd frontend cd frontend
npm install && npm run dev npm install && npm run dev
``` ```
开发前端:http://localhost:5173(代理 `/api`8000 开发前端:http://localhost:5173(代理 `/api`23568
生产网关本地模拟: 生产网关本地模拟:
+1 -1
View File
@@ -2,7 +2,7 @@ DATABASE_URL=postgresql://gradeapp:postgres@127.0.0.1:5432/student_archive
SECRET_KEY=dev-secret-key-change-in-production SECRET_KEY=dev-secret-key-change-in-production
CORS_ORIGINS=http://localhost:5173,http://localhost:23566 CORS_ORIGINS=http://localhost:5173,http://localhost:23566
UPLOAD_DIR=uploads UPLOAD_DIR=uploads
API_PORT=8000 API_PORT=23568
OLLAMA_BASE_URL=http://127.0.0.1:11434 OLLAMA_BASE_URL=http://127.0.0.1:11434
OLLAMA_MODEL=qwen2.5:7b OLLAMA_MODEL=qwen2.5:7b
FLUCTUATION_THRESHOLD=0.08 FLUCTUATION_THRESHOLD=0.08
+1 -1
View File
@@ -8,7 +8,7 @@ set -euo pipefail
REPO_URL="${REPO_URL:-https://git.bz121.com/dekun/secondary-school-grade-archive.git}" REPO_URL="${REPO_URL:-https://git.bz121.com/dekun/secondary-school-grade-archive.git}"
INSTALL_DIR="${INSTALL_DIR:-/opt/secondary-school-grade-archive}" INSTALL_DIR="${INSTALL_DIR:-/opt/secondary-school-grade-archive}"
WEB_PORT="${WEB_PORT:-23566}" WEB_PORT="${WEB_PORT:-23566}"
API_PORT="${API_PORT:-8000}" API_PORT="${API_PORT:-23568}"
BRANCH="${BRANCH:-main}" BRANCH="${BRANCH:-main}"
NODE_MAJOR="${NODE_MAJOR:-20}" NODE_MAJOR="${NODE_MAJOR:-20}"
PIP_MIRROR="${PIP_MIRROR:-https://pypi.tuna.tsinghua.edu.cn/simple}" PIP_MIRROR="${PIP_MIRROR:-https://pypi.tuna.tsinghua.edu.cn/simple}"
+1 -1
View File
@@ -27,7 +27,7 @@ function loadEnv() {
const env = loadEnv() const env = loadEnv()
const webPort = env.WEB_PORT || '23566' const webPort = env.WEB_PORT || '23566'
const apiPort = env.API_PORT || '8000' const apiPort = env.API_PORT || '23568'
const venvPython = path.join(root, 'backend', 'venv', 'bin', 'python') const venvPython = path.join(root, 'backend', 'venv', 'bin', 'python')
module.exports = { module.exports = {
+1 -1
View File
@@ -9,7 +9,7 @@ if (fs.existsSync(envPath)) {
} }
const PORT = Number(process.env.WEB_PORT || 23566) const PORT = Number(process.env.WEB_PORT || 23566)
const API_TARGET = process.env.API_TARGET || 'http://127.0.0.1:8000' const API_TARGET = process.env.API_TARGET || 'http://127.0.0.1:23568'
const STATIC_ROOT = path.join(__dirname, '../../frontend/dist') const STATIC_ROOT = path.join(__dirname, '../../frontend/dist')
const app = express() const app = express()
+4 -3
View File
@@ -13,14 +13,14 @@
| 系统 | Ubuntu 20.04 / 22.04 / 24.04 | | 系统 | Ubuntu 20.04 / 22.04 / 24.04 |
| 用户 | **root** | | 用户 | **root** |
| 目录 | `/opt/secondary-school-grade-archive` | | 目录 | `/opt/secondary-school-grade-archive` |
| 端口 | **23566**Web + API 统一入口 | | 端口 | **23566** 对外 Web**23568** 内部 API(仅本机 |
| 反向代理 | **不包含**,请自行配置 | | 反向代理 | **不包含**,请自行配置 |
### 架构 ### 架构
``` ```
浏览器 → :23566 (PM2: grade-web, Express 静态 + /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 (本机) └──→ PostgreSQL (本机)
└──→ uploads/ └──→ uploads/
└──→ Ollama (本机可选, :11434) └──→ Ollama (本机可选, :11434)
@@ -72,7 +72,8 @@ bash deploy/install.sh
| 变量 | 默认 | 说明 | | 变量 | 默认 | 说明 |
|------|------|------| |------|------|------|
| `WEB_PORT` | 23566 | 对外 Web 端口 | | `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 连接 | | `DATABASE_URL` | 自动生成 | PostgreSQL 连接 |
| `SECRET_KEY` | 自动生成 | JWT 密钥 | | `SECRET_KEY` | 自动生成 | JWT 密钥 |
| `UPLOAD_DIR` | `.../uploads` | 错题图片目录 | | `UPLOAD_DIR` | `.../uploads` | 错题图片目录 |
+1 -1
View File
@@ -7,7 +7,7 @@ export default defineConfig({
port: 5173, port: 5173,
proxy: { proxy: {
'/api': { '/api': {
target: 'http://localhost:8000', target: 'http://localhost:23568',
changeOrigin: true, changeOrigin: true,
}, },
}, },