feat: 完善后台部署与API前缀配置
This commit is contained in:
1 parent
c821d6c7db
commit
2b1035dbc8
7 files changed
+54
-2
No files matched your search
@@ -0,0 +1,30 @@
|
||||
# 部署说明
|
||||
|
||||
## 本地开发
|
||||
|
||||
API 默认监听 `http://localhost:3001`,管理后台默认监听 `http://localhost:3000`。后台开发服务器会把 `/api` 请求代理到 API,并移除 `/api` 前缀,因此本地不需要额外配置跨域。
|
||||
|
||||
## Nginx 反向代理
|
||||
|
||||
生产环境建议使用同源路径:
|
||||
|
||||
```nginx
|
||||
location /admin/ {
|
||||
try_files $uri $uri/ /admin/index.html;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:3001/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Request-ID $request_id;
|
||||
}
|
||||
```
|
||||
|
||||
构建管理后台时使用:
|
||||
|
||||
```bash
|
||||
VITE_APP_BASE_PATH=/admin/ VITE_API_BASE_URL=/api pnpm --filter @personal-brand/admin build
|
||||
```
|
||||
|
||||
如果希望 API 服务自身也带前缀,可设置 `API_PREFIX=api`。使用 Nginx 去前缀转发时保持默认空值即可,避免重复 `/api/api`。
|
||||
Reference in new issue
Block a user