From 6fe2e23df00e4884cd08627bc58f7d3999c24b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aron=20Sch=C3=BCler?= Date: Wed, 12 Jun 2024 09:25:25 +0200 Subject: [PATCH] feat: dont redirect if heading towards root url --- src/utils/AuthRedirects.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/AuthRedirects.tsx b/src/utils/AuthRedirects.tsx index 8efb298..9c2d6b7 100644 --- a/src/utils/AuthRedirects.tsx +++ b/src/utils/AuthRedirects.tsx @@ -5,8 +5,10 @@ import { UserContext } from "../provider/UserContext"; export const RedirectIfNotLoggedIn = ({ children }: PropsWithChildren) => { const { user } = useContext(UserContext); - const target = "/login" + `?redirect=${window.location.pathname}`; - + let target = "/login"; + if (window.location.pathname !== "/") { + target = target + `?redirect=${window.location.pathname}`; + } return !user?.uid ? : children; };