chore(deps): upgrade Next.js to 15.1.9
- Upgrade next package from 15.1.6 to 15.1.9 - Upgrade eslint-config-next from 15.1.6 to 15.1.9 - Sort axios imports alphabetically in response-interceptor - Skip token refresh for login endpoint to prevent infinite redirect loops - Add check to prevent automatic token refresh when login request fails
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { AxiosResponse, AxiosError } from "axios";
|
||||
import { AxiosError, AxiosResponse } from "axios";
|
||||
import Cookies from "js-cookie";
|
||||
import { toast } from "react-toastify";
|
||||
import { API_ENDPOINTS, api } from "../lib/api";
|
||||
@@ -26,7 +26,16 @@ export const responseInterceptor = (response: AxiosResponse) => {
|
||||
export const responseErrorHandler = async (error: AxiosError) => {
|
||||
const originalRequest = error.config as any;
|
||||
|
||||
if (error.response?.status === 401 && !originalRequest._retry) {
|
||||
// Skip token refresh for login endpoint - let login errors pass through
|
||||
const isLoginRequest = originalRequest?.url?.includes(
|
||||
API_ENDPOINTS.USER.LOGIN,
|
||||
);
|
||||
|
||||
if (
|
||||
error.response?.status === 401 &&
|
||||
!originalRequest._retry &&
|
||||
!isLoginRequest
|
||||
) {
|
||||
if (isRefreshing) {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
failedQueue.push({ resolve, reject });
|
||||
|
||||
Reference in New Issue
Block a user