front/test-rbac-request.md
2025-12-27 16:29:05 +08:00

55 lines
1.8 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.

# RBAC 请求对比测试
## 开发环境请求(成功)
```bash
curl 'http://localhost:5174/rbac/auth/login?account=admin&password=123456' \
-X 'POST' \
-H 'Accept: application/json' \
-H 'Accept-Language: zh-CN,zh;q=0.9' \
-H 'Content-Length: 0' \
-H 'Origin: http://localhost:5174' \
-H 'Referer: http://localhost:5174/login'
```
**配置:**
- 前端请求:`/rbac/auth/login`
- Vite 代理:`/rbac` -> `http://43.139.210.35:5281`
- 最终请求:`http://43.139.210.35:5281/rbac/auth/login`
## 生产环境请求(应该)
```bash
curl 'https://oms.nanafa.com/rbac/auth/login?account=admin&password=123456' \
-X 'POST' \
-H 'Accept: application/json' \
-H 'Accept-Language: zh-CN,zh;q=0.9' \
-H 'Content-Length: 0' \
-H 'Origin: https://oms.nanafa.com' \
-H 'Referer: https://oms.nanafa.com/login'
```
**配置:**
- 前端请求:`/rbac/auth/login`
- nginx 代理:`/rbac` -> `http://43.139.210.35:5281`
- 最终请求:`http://43.139.210.35:5281/rbac/auth/login`
## 关键差异
1. **协议**:开发环境使用 HTTP,生产环境使用 HTTPS
2. **代理**:开发环境使用 Vite 代理,生产环境使用 nginx 代理
3. **请求头**:Origin 和 Referer 不同
## 可能的问题
1. **nginx 配置未更新**:服务器上的 nginx 配置可能还是旧的
2. **HTTPS 配置**:nginx 可能监听的是 80 端口,但实际访问是 HTTPS(443)
3. **CORS 问题**:后端可能需要配置允许 `https://oms.nanafa.com` 的跨域请求
## 检查清单
- [ ] 确认 nginx 配置已更新到服务器
- [ ] 确认 nginx 监听的是正确的端口(80 或 443)
- [ ] 确认后端服务器 `http://43.139.210.35:5281` 可以访问
- [ ] 检查浏览器控制台的网络请求,看实际请求的 URL
- [ ] 检查浏览器控制台的错误信息