From 80d67ccb730bd5f767562ed0e6dedfcb3353a64f Mon Sep 17 00:00:00 2001 From: freedakgmail Date: Wed, 29 Jul 2026 08:44:38 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=B7=BB=E5=8A=A0=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E5=90=AF=E5=8A=A8=E5=91=BD=E4=BB=A4=E5=88=B0?= =?UTF-8?q?=20run.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/run.md b/run.md index 497a31d..22396e3 100644 --- a/run.md +++ b/run.md @@ -7,4 +7,34 @@ | 总部管理员 | 123 | hq | | 区域经理 | 123 | regional | | 潘家园店长 | 123 | store | -| 商品部 | 123 | dept | \ No newline at end of file +| 商品部 | 123 | dept | + +## 本地开发启动 + +### 1. 启动后端服务 + +```bash +cd server && npm run dev +``` + +后端运行在 `http://localhost:3333`,连接本地 PostgreSQL(`localhost:5432`,数据库 `bill_query`)。 + +### 2. 启动反向隧道(线上前端访问本地后端) + +线上 Nginx 将 `/api/` 代理到远程 `127.0.0.1:13333`,通过反向 SSH 隧道转发到本地后端: + +```bash +sshpass -p 'Why_701208' ssh -o StrictHostKeyChecking=accept-new -N -R 13333:localhost:3333 ubuntu@dm.all8ai.top +``` + +### 3. 访问 + +- **线上前端**:`https://dm.all8ai.top`(API请求通过隧道转发到本地后端) +- **本地前端开发**:`cd client && npm run dev`,访问 `http://localhost:5173`(Vite proxy 自动转发 `/api` 到 `localhost:3333`) + +### 注意事项 + +- 本地 PostgreSQL 端口 5432 被 Homebrew PostgreSQL 占用,数据库 `bill_query` 在本地 +- 反向隧道将远程 13333 映射到本地 3333,服务器 Nginx 配置 `/api/` → `127.0.0.1:13333` +- 隧道断开后线上前端 API 会失效,需重新执行隧道命令 +- `server/.env` 中 `DB_PORT=5432` 连接本地数据库,不要改为 5433 \ No newline at end of file