diff --git a/src/components/Authentication/Clerk/ClerkLogin.tsx b/src/components/Authentication/Clerk/ClerkLogin.tsx
index f2a8d782c..261b18931 100644
--- a/src/components/Authentication/Clerk/ClerkLogin.tsx
+++ b/src/components/Authentication/Clerk/ClerkLogin.tsx
@@ -4,16 +4,14 @@ import { useRouter } from "next/router";
export default function ClerkLogin() {
const { query } = useRouter();
- const redirectUrl = query.redirectUrl
- ? (query.return_to as string)
- : undefined;
+ const returnTo = query.return_to as string;
return (
);
}
diff --git a/src/components/Authentication/Clerk/ClerkRegistration.tsx b/src/components/Authentication/Clerk/ClerkRegistration.tsx
index bd876ab13..5986d2894 100644
--- a/src/components/Authentication/Clerk/ClerkRegistration.tsx
+++ b/src/components/Authentication/Clerk/ClerkRegistration.tsx
@@ -4,7 +4,7 @@ import { useRouter } from "next/router";
export default function ClerkRegistration() {
const { query } = useRouter();
- const redirectUrl = query.redirectUrl ? query.return_to : undefined;
+ const returnTo = query.return_to as string;
return (
@@ -15,7 +15,7 @@ export default function ClerkRegistration() {
routing="path"
signInUrl="/login"
signInForceRedirectUrl={
- redirectUrl ? `/?return_to=${redirectUrl}` : undefined
+ returnTo ? `/?return_to=${returnTo}` : undefined
}
/>
diff --git a/src/components/Authentication/Kratos/KratosAuthSessionChecker.tsx b/src/components/Authentication/Kratos/KratosAuthSessionChecker.tsx
index 2e1d47f99..c8b13a23f 100644
--- a/src/components/Authentication/Kratos/KratosAuthSessionChecker.tsx
+++ b/src/components/Authentication/Kratos/KratosAuthSessionChecker.tsx
@@ -27,7 +27,7 @@ export default function KratosAuthSessionChecker({
const { data } = await ory.toSession();
setSession(data);
} catch (err) {
- const url = window.location.pathname;
+ const url = encodeURIComponent(window.location.href);
switch ((err as AxiosError).response?.status) {
case 403:
push(`/login?aal=aal2&return_to=${url}`);