mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
Update client.ts
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import axios, { AxiosError, InternalAxiosRequestConfig } from 'axios'
|
import axios, { AxiosError, InternalAxiosRequestConfig } from 'axios'
|
||||||
import { tokenStorage, isTokenExpired, tokenRefreshManager } from '../utils/token'
|
import { tokenStorage, isTokenExpired, tokenRefreshManager, safeRedirectToLogin } from '../utils/token'
|
||||||
|
|
||||||
const API_BASE_URL = import.meta.env.VITE_API_URL || '/api'
|
const API_BASE_URL = import.meta.env.VITE_API_URL || '/api'
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ apiClient.interceptors.request.use(async (config: InternalAxiosRequestConfig) =>
|
|||||||
} else {
|
} else {
|
||||||
// Refresh не удался - редирект на логин
|
// Refresh не удался - редирект на логин
|
||||||
tokenStorage.clearTokens()
|
tokenStorage.clearTokens()
|
||||||
window.location.href = '/login'
|
safeRedirectToLogin()
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ apiClient.interceptors.response.use(
|
|||||||
} else {
|
} else {
|
||||||
// Refresh не удался
|
// Refresh не удался
|
||||||
tokenStorage.clearTokens()
|
tokenStorage.clearTokens()
|
||||||
window.location.href = '/login'
|
safeRedirectToLogin()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user