Fix for production
This commit is contained in:
@@ -12,8 +12,10 @@ declare module 'axios' {
|
||||
}
|
||||
}
|
||||
|
||||
const apiBaseURL = import.meta.env.VITE_API_BASE_URL || '/api';
|
||||
|
||||
export const apiClient = axios.create({
|
||||
baseURL: '/api',
|
||||
baseURL: apiBaseURL,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
@@ -96,7 +98,7 @@ apiClient.interceptors.response.use(
|
||||
}
|
||||
|
||||
try {
|
||||
const { data } = await axios.post('/api/admin/auth/refresh', { refreshToken });
|
||||
const { data } = await axios.post(`${apiBaseURL}/admin/auth/refresh`, { refreshToken });
|
||||
const newToken = data.data?.accessToken || data.accessToken;
|
||||
localStorage.setItem('admin_access_token', newToken);
|
||||
apiClient.defaults.headers.common.Authorization = `Bearer ${newToken}`;
|
||||
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_API_BASE_URL?: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
Reference in New Issue
Block a user