diff --git a/frontend/plugins/axios.ts b/frontend/plugins/axios.ts index 296a285..6218f29 100644 --- a/frontend/plugins/axios.ts +++ b/frontend/plugins/axios.ts @@ -8,7 +8,9 @@ export default defineNuxtPlugin(() => { const { token, logout } = useAuth(); const axios = axiosOriginal.create({ - baseURL: config.public.API_BASE_URL + timeout: 30000, + timeoutErrorMessage: "فرآیند بیش از حد انتظار طول کشید", + baseURL: config.public.API_BASE_URL, }); axios.interceptors.request.use((config) => { @@ -16,29 +18,32 @@ export default defineNuxtPlugin(() => { !config.url?.includes(API_ENDPOINTS.auth.signin) && !config.url?.includes(API_ENDPOINTS.account.send_otp) ) { - config.headers.Authorization = token.value ? `Bearer ${token.value}` : undefined; + config.headers.Authorization = token.value + ? `Bearer ${token.value}` + : undefined; } return config; }); - axios.interceptors.response.use((response) => { - return response; - }, async function(error) { + axios.interceptors.response.use( + (response) => { + return response; + }, + async function (error) { + await Logger.axiosErrorLog(error); - await Logger.axiosErrorLog(error); + // if (error.status === 401) { + // logout(); + // } - // if (error.status === 401) { - // logout(); - // } - - return Promise.reject(error); - }); + return Promise.reject(error); + } + ); return { provide: { - axios - } + axios, + }, }; - -}); \ No newline at end of file +});