docs: 添加本地开发启动命令到 run.md

This commit is contained in:
freedakgmail
2026-07-29 08:44:38 +08:00
parent 42e83696a0
commit 80d67ccb73
+31 -1
View File
@@ -7,4 +7,34 @@
| 总部管理员 | 123 | hq |
| 区域经理 | 123 | regional |
| 潘家园店长 | 123 | store |
| 商品部 | 123 | dept |
| 商品部 | 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