From 0d4c3c3877bee1c92f574d26c67118dadb4a3dc7 Mon Sep 17 00:00:00 2001
From: guonan <guonan201020@163.com>
Date: 星期四, 01 五月 2025 17:06:20 +0800
Subject: [PATCH] 后端ip暴露

---
 src/api/requestTR.js |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/api/requestTR.js b/src/api/requestTR.js
index c404aac..01feb22 100644
--- a/src/api/requestTR.js
+++ b/src/api/requestTR.js
@@ -1,13 +1,26 @@
 import axios from "axios";
 
+// 鍒ゆ柇褰撳墠鏄惁鏄紑鍙戠幆澧�
+let API_URL;
+
+if (process.env.NODE_ENV === 'development') {
+  // 寮�鍙戠幆澧冧娇鐢� '/api'
+  API_URL = '/api';
+} else {
+  // 鐢熶骇鐜浣跨敤瀹為檯鐨勯厤缃湴鍧�
+  API_URL = `${BASE_URL.endsWith('/') ? BASE_URL.slice(0, -1) : BASE_URL}/api`;
+}
+
 // 鍒涘缓 Axios 瀹炰緥
 const instance = axios.create({
-  baseURL: "/api", // 浣跨敤浣犻厤缃殑 /auth 浠g悊
+  baseURL: API_URL,
   timeout: 1000 * 60, // 璇锋眰瓒呮椂鏃堕棿锛堝崟浣嶏細姣锛�
   headers: {
-    "Content-Type": "application/x-www-form-urlencoded", // 榛樿璇锋眰澶碼pplication/json
+    "Content-Type": "application/x-www-form-urlencoded", // 榛樿璇锋眰澶�
   },
 });
+
+console.log('褰撳墠 BaseUrl:', API_URL);
 // 璇锋眰鎷︽埅鍣�
 // instance.interceptors.request.use(
 //   (config) => {

--
Gitblit v1.9.3