resolve refresh

This commit is contained in:
Cjsah
2024-06-16 10:51:12 +08:00
parent 96a3b6b802
commit 94aaee8d9b
2 changed files with 19 additions and 13 deletions

View File

@@ -1,14 +1,25 @@
import axios from "axios";
const SECOND = 1000;
export const baseUrl = () => {
return localStorage.getItem("remoteIp");
};
const remoteIp = ref(localStorage.getItem("remoteIp"));
const ajax = axios.create({
// baseURL: import.meta.env.VITE_API || location.origin,
timeout: 120 * SECOND,
});
ajax.interceptors.request.use((config) => {
config.baseURL = remoteIp.value;
return config;
});
export default ajax;
export const setRemoteIp = (ip) => {
remoteIp.value = ip;
localStorage.setItem("remoteIp", ip);
};
export const baseUrl = () => {
return remoteIp.value;
};