From 857f46ad17f10042d82749164caddd5250a7d3b9 Mon Sep 17 00:00:00 2001 From: qiube <18969599531@163.com> Date: Fri, 26 Dec 2025 14:11:46 +0800 Subject: [PATCH] =?UTF-8?q?chore(config):=20=E6=9B=B4=E6=96=B0=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E7=8E=AF=E5=A2=83API=E9=85=8D=E7=BD=AE=E5=92=8C?= =?UTF-8?q?=E4=BB=A3=E7=90=86=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将生产环境API基础URL从绝对路径改为相对路径 /api - 修改开发环境代理配置,后端目标端口从 8082 改为 18082 - 更新相关注释和错误提示信息 - 移除生产环境配置中的服务器IP地址硬编码 - 添加 --- .env.production | 12 +++++------- README.md | 2 +- vite.config.js | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.env.production b/.env.production index 27a9aef..3664842 100644 --- a/.env.production +++ b/.env.production @@ -1,8 +1,6 @@ -# 生产环境配置 -# 服务器地址: 175.178.252.59 - -# 后端API地址 -VITE_API_BASE_URL=http://175.178.252.59:8082/api - -# PingPong模式(sandbox/production)`nVITE_PINGPONG_MODE=sandbox +# 鐢熶骇鐜閰嶇疆 +# 浣跨敤鐩稿璺緞锛岄€氳繃Nginx浠g悊鍒板悗绔? +# API鍩虹URL锛堢浉瀵硅矾寰勶紝閫氳繃Nginx浠g悊锛?# 閲嶈锛氬繀椤讳娇鐢ㄧ浉瀵硅矾寰?/api锛屼笉瑕佷娇鐢ㄥ畬鏁碪RL +VITE_API_BASE_URL=/api +# PingPong妯″紡锛坰andbox/production锛?VITE_PINGPONG_MODE=sandbox diff --git a/README.md b/README.md index 42ee5d1..fdf84bc 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ MTKJPAY-FRONT/ 在 `src/api/request.js` 中配置后端API地址: ```javascript const service = axios.create({ - baseURL: 'http://localhost:8082/api', + baseURL: '/api', // 使用相对路径,通过Nginx代理 timeout: 10000 }) ``` diff --git a/vite.config.js b/vite.config.js index 0718d6f..b51322e 100644 --- a/vite.config.js +++ b/vite.config.js @@ -27,7 +27,7 @@ export default defineConfig({ port: 3000, proxy: { '/api': { - target: 'http://127.0.0.1:8082', // 使用 127.0.0.1 而不是 localhost,避免 IPv6 问题 + target: 'http://127.0.0.1:18082', changeOrigin: true, secure: false, ws: true, @@ -35,7 +35,7 @@ export default defineConfig({ configure: (proxy, options) => { proxy.on('error', (err, req, res) => { console.error('代理错误:', err.message) - console.error('请确保后端服务已启动在 http://127.0.0.1:8082') + console.error('请确保后端服务已启动在 http://127.0.0.1:18082') }) } }