fix(auth): prevent login redirect loop and concurrent refresh calls
- Added check to avoid redirecting to `/login` if already on the login page. - Prevented multiple simultaneous `refreshUser` calls by adding an `isLoading` guard. - Improved `useEffect` cleanup in `auth-provider` to handle components unmounting.
This commit is contained in:
@@ -53,7 +53,10 @@ api.interceptors.response.use(
|
||||
} catch (refreshError) {
|
||||
// If refresh fails, we might want to redirect to login on the client
|
||||
if (typeof window !== "undefined") {
|
||||
window.location.href = "/login";
|
||||
// On évite de rediriger vers login si on y est déjà pour éviter les boucles
|
||||
if (!window.location.pathname.includes("/login")) {
|
||||
window.location.href = "/login";
|
||||
}
|
||||
}
|
||||
return Promise.reject(refreshError);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user