本地开发环境使用代理模式

This commit is contained in:
谢思 2026-01-20 16:53:44 +08:00
parent be55a17384
commit bd678d53d9
2 changed files with 13 additions and 12 deletions

View File

@ -202,6 +202,7 @@
"eslintConfig": { "eslintConfig": {
"extends": "react-app" "extends": "react-app"
}, },
"proxy": "https://testforgeplus.trustie.net",
"port": "3007", "port": "3007",
"devDependencies": { "devDependencies": {
"@babel/core": "^7.23.6", "@babel/core": "^7.23.6",

View File

@ -32,7 +32,7 @@ export function initAxiosInterceptors(props) {
// 判断网络是否连接 // 判断网络是否连接
initOnlineOfflineListener(); initOnlineOfflineListener();
var proxy = "https://testforgeplus.trustie.net"; // var proxy = "https://testforgeplus.trustie.net";
// var proxy = "http://172.20.32.201:4000"; // var proxy = "http://172.20.32.201:4000";
// var proxy = "https://www.gitlink.org.cn"; // var proxy = "https://www.gitlink.org.cn";
@ -45,18 +45,18 @@ export function initAxiosInterceptors(props) {
requestProxy(config); requestProxy(config);
let url = `/api${config.url}`; let url = `/api${config.url}`;
if (window.location.port === "3007") { // if (window.location.port === "3007") {
config.url = `${proxy}${url}`; // config.url = `${proxy}${url}`;
if (config.url.indexOf('?') === -1) { // if (config.url.indexOf('?') === -1) {
config.url = `${config.url}`; // config.url = `${config.url}`;
} else { // } else {
config.url = `${config.url}`; // config.url = `${config.url}`;
} // }
} else { // } else {
config.url = url; // config.url = url;
} // }
config.withCredentials = false; config.withCredentials = false;
// config.url = url; config.url = url;
return config; return config;
}, },
err => { err => {