diff --git a/client/src/contexts/ParametresContext.tsx b/client/src/contexts/ParametresContext.tsx index 8fa98c0..dd8ab75 100644 --- a/client/src/contexts/ParametresContext.tsx +++ b/client/src/contexts/ParametresContext.tsx @@ -2,6 +2,7 @@ // Lit depuis la BDD via tRPC, avec fallback sur les valeurs par défaut import { createContext, useContext, useCallback, type ReactNode } from 'react'; +import { useLocation } from 'wouter'; import { trpc } from '@/lib/trpc'; export interface Parametres { @@ -37,10 +38,14 @@ function parseNum(val: string | null | undefined, fallback: number): number { export function ParametresProvider({ children }: { children: ReactNode }) { const utils = trpc.useUtils(); + const [pathname] = useLocation(); + // Ne pas faire la requête sur /login pour éviter les erreurs 401 qui causent des clignotements + const isLoginPage = pathname === '/login'; const { data: rawParams, isLoading } = trpc.parametres.get.useQuery(undefined, { retry: false, refetchOnWindowFocus: false, + enabled: !isLoginPage, }); const setBulkMutation = trpc.parametres.setBulk.useMutation({ diff --git a/client/src/main.tsx b/client/src/main.tsx index 8adf6f5..06eb69f 100644 --- a/client/src/main.tsx +++ b/client/src/main.tsx @@ -18,6 +18,9 @@ const redirectToLoginIfUnauthorized = (error: unknown) => { if (!isUnauthorized) return; + // Ne pas rediriger si on est déjà sur la page de login (évite la boucle) + if (window.location.pathname === '/login') return; + window.location.href = getLoginUrl(); };