From c0f5c6acc8d234200869144ccd2d783ed554efb6 Mon Sep 17 00:00:00 2001 From: Potenz Date: Fri, 3 Oct 2025 22:47:04 +0530 Subject: [PATCH] fix(auth redirect fixed) --- apps/Frontend/src/lib/queryClient.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/Frontend/src/lib/queryClient.ts b/apps/Frontend/src/lib/queryClient.ts index 6d65385..bdb3d8f 100644 --- a/apps/Frontend/src/lib/queryClient.ts +++ b/apps/Frontend/src/lib/queryClient.ts @@ -4,7 +4,7 @@ const API_BASE_URL = import.meta.env.VITE_API_BASE_URL_BACKEND ?? ""; async function throwIfResNotOk(res: Response) { if (!res.ok) { - if (res.status === 401) { + if (res.status === 401 || res.status === 403) { localStorage.removeItem("token"); if (!window.location.pathname.startsWith("/auth")) { window.location.href = "/auth"; @@ -109,7 +109,10 @@ export const getQueryFn: (options: { credentials: "include", }); - if (unauthorizedBehavior === "returnNull" && res.status === 401) { + if ( + unauthorizedBehavior === "returnNull" && + (res.status === 401 || res.status === 403) + ) { return null; }