fix(login): не перехватывать 401 на /v1/admin/login
Исключает refresh/reload формы при неверном пароле. Refs EventHub/EventHubFrontAdmin#12 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+9
-1
@@ -10,6 +10,9 @@ const apiClient = axios.create({
|
|||||||
|
|
||||||
type RetryConfig = InternalAxiosRequestConfig & { _retry?: boolean };
|
type RetryConfig = InternalAxiosRequestConfig & { _retry?: boolean };
|
||||||
|
|
||||||
|
const isLoginRequest = (config?: InternalAxiosRequestConfig) =>
|
||||||
|
Boolean(config?.url?.includes('/v1/admin/login'));
|
||||||
|
|
||||||
let isRefreshing = false;
|
let isRefreshing = false;
|
||||||
let pendingRequests: Array<{
|
let pendingRequests: Array<{
|
||||||
resolve: (token: string) => void;
|
resolve: (token: string) => void;
|
||||||
@@ -45,7 +48,12 @@ apiClient.interceptors.response.use(
|
|||||||
(response) => response,
|
(response) => response,
|
||||||
async (error: AxiosError) => {
|
async (error: AxiosError) => {
|
||||||
const originalRequest = error.config as RetryConfig | undefined;
|
const originalRequest = error.config as RetryConfig | undefined;
|
||||||
if (!originalRequest || error.response?.status !== 401 || originalRequest._retry) {
|
if (
|
||||||
|
!originalRequest ||
|
||||||
|
error.response?.status !== 401 ||
|
||||||
|
originalRequest._retry ||
|
||||||
|
isLoginRequest(originalRequest)
|
||||||
|
) {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user