Bladeren bron

feat: 更换请求地址

sunxiao 1 dag geleden
bovenliggende
commit
ffdaac0926
2 gewijzigde bestanden met toevoegingen van 8 en 2 verwijderingen
  1. 1 1
      .env.production
  2. 7 1
      src/utils/request.ts

+ 1 - 1
.env.production

@@ -1,4 +1,4 @@
 # 请求地址
-VITE_BASE_URL=http://10.1.100.119:8888
+VITE_BASE_URL=http://localhost:8888
 # 请求前缀
 VITE_BASE_PREFIX='' 

+ 7 - 1
src/utils/request.ts

@@ -12,7 +12,13 @@ const { notification } = createDiscreteApi(["notification"]);
 
 // const useStore = useUserStore();
 
-export const url = import.meta.env.VITE_BASE_URL;
+const { hostname } = window.location;
+
+// export const url = import.meta.env.VITE_BASE_URL;
+export const url = 'http://' + hostname + ':8888';
+
+console.log("current-url", url);
+
 export const prefix = import.meta.env.VITE_BASE_PREFIX;
 export const baseURL = url + prefix;