chore(config): 更新生产环境API配置和代理设置
- 将生产环境API基础URL从绝对路径改为相对路径 /api - 修改开发环境代理配置,后端目标端口从 8082 改为 18082 - 更新相关注释和错误提示信息 - 移除生产环境配置中的服务器IP地址硬编码 - 添加
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
# 生产环境配置
|
# 鐢熶骇鐜閰嶇疆
|
||||||
# 服务器地址: 175.178.252.59
|
# 浣跨敤鐩稿璺緞锛岄€氳繃Nginx浠g悊鍒板悗绔?
|
||||||
|
# API鍩虹URL锛堢浉瀵硅矾寰勶紝閫氳繃Nginx浠g悊锛?# 閲嶈锛氬繀椤讳娇鐢ㄧ浉瀵硅矾寰?/api锛屼笉瑕佷娇鐢ㄥ畬鏁碪RL
|
||||||
# 后端API地址
|
VITE_API_BASE_URL=/api
|
||||||
VITE_API_BASE_URL=http://175.178.252.59:8082/api
|
|
||||||
|
|
||||||
# PingPong模式(sandbox/production)`nVITE_PINGPONG_MODE=sandbox
|
|
||||||
|
|
||||||
|
# PingPong妯″紡锛坰andbox/production锛?VITE_PINGPONG_MODE=sandbox
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ MTKJPAY-FRONT/
|
|||||||
在 `src/api/request.js` 中配置后端API地址:
|
在 `src/api/request.js` 中配置后端API地址:
|
||||||
```javascript
|
```javascript
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
baseURL: 'http://localhost:8082/api',
|
baseURL: '/api', // 使用相对路径,通过Nginx代理
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export default defineConfig({
|
|||||||
port: 3000,
|
port: 3000,
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: 'http://127.0.0.1:8082', // 使用 127.0.0.1 而不是 localhost,避免 IPv6 问题
|
target: 'http://127.0.0.1:18082',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
secure: false,
|
secure: false,
|
||||||
ws: true,
|
ws: true,
|
||||||
@@ -35,7 +35,7 @@ export default defineConfig({
|
|||||||
configure: (proxy, options) => {
|
configure: (proxy, options) => {
|
||||||
proxy.on('error', (err, req, res) => {
|
proxy.on('error', (err, req, res) => {
|
||||||
console.error('代理错误:', err.message)
|
console.error('代理错误:', err.message)
|
||||||
console.error('请确保后端服务已启动在 http://127.0.0.1:8082')
|
console.error('请确保后端服务已启动在 http://127.0.0.1:18082')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user