diff --git a/patchnotes-web/src/auth/stytch.ts b/patchnotes-web/src/auth/stytch.ts index 460d7a72..3f4532c0 100644 --- a/patchnotes-web/src/auth/stytch.ts +++ b/patchnotes-web/src/auth/stytch.ts @@ -22,10 +22,10 @@ if (import.meta.env.DEV) { } export function getStytchLoginConfig(returnUrl?: string) { - const base = `${window.location.origin}/authenticate` - const redirectURL = returnUrl - ? `${base}?returnUrl=${encodeURIComponent(returnUrl)}` - : base + if (returnUrl) { + localStorage.setItem('stytch_return_url', returnUrl) + } + const redirectURL = `${window.location.origin}/authenticate` return { products, diff --git a/patchnotes-web/src/pages/Authenticate.tsx b/patchnotes-web/src/pages/Authenticate.tsx index 1f1dd9fe..99386683 100644 --- a/patchnotes-web/src/pages/Authenticate.tsx +++ b/patchnotes-web/src/pages/Authenticate.tsx @@ -12,7 +12,10 @@ export function Authenticate() { const { token, tokenType, returnUrl } = useMemo(() => { const params = new URLSearchParams(window.location.search) - const raw = params.get('returnUrl') + // Check localStorage first, then fall back to query param for backwards compat + const stored = localStorage.getItem('stytch_return_url') + localStorage.removeItem('stytch_return_url') + const raw = stored ?? params.get('returnUrl') return { token: params.get('token'), tokenType: params.get('stytch_token_type'),