From 893ea3d930a4c565909988dbcb383b5f64d8c1cc Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Sun, 30 Jul 2023 12:15:29 +0100 Subject: [PATCH] fix: support SSR for login button --- components/pages/home/LoginButton.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/pages/home/LoginButton.tsx b/components/pages/home/LoginButton.tsx index 1bcdee3..b5e866a 100644 --- a/components/pages/home/LoginButton.tsx +++ b/components/pages/home/LoginButton.tsx @@ -6,7 +6,11 @@ import Link from "next/link"; export function LoginButton() { const { data: session } = useSession(); - const params = new URLSearchParams(document.location.search); + const callbackUrl = + typeof window === "undefined" + ? undefined + : new URLSearchParams(document.location.search).get("callbackUrl") ?? + undefined; if (session) { return ( @@ -31,7 +35,7 @@ export function LoginButton() { variant="outline" onClick={() => signIn("authentik", { - callbackUrl: params.get("callbackUrl") ?? undefined, + callbackUrl, }) } >