Files
SBrainCO/run.md
T
2026-07-29 08:44:38 +08:00

40 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
当前数据库是本机Homebrew PostgreSQL 15,数据库名为 bill_query,端口5432,仅监听 localhost;当前用户 freedak 是超级用户,本机认证方式为 trust。这适合本机开发,但不适合直接照搬到服务器生产环境。前端浏览器也不应直接连接PostgreSQL,必须通过后端API访问。
## 登录账号
| 用户名 | 密码 | 角色 |
|--------|------|------|
| 总部管理员 | 123 | hq |
| 区域经理 | 123 | regional |
| 潘家园店长 | 123 | store |
| 商品部 | 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