From 7be1e9a738b82d0923ea901677147c3bc810acef Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sun, 19 Oct 2025 00:53:17 +0000 Subject: [PATCH] Honor next query param after login cgen-5835fa17c9d447c88d8e17ea9c138783 --- client/pages/Login.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/pages/Login.tsx b/client/pages/Login.tsx index 5484a20a..faa2bf53 100644 --- a/client/pages/Login.tsx +++ b/client/pages/Login.tsx @@ -63,14 +63,17 @@ export default function Login() { } = useAuth(); const { info: toastInfo, error: toastError } = useAethexToast(); - // After auth resolves and a user exists, navigate to dashboard + // After auth resolves and a user exists, navigate to next path or dashboard useEffect(() => { if (!loading && user) { - navigate(profileComplete ? "/dashboard" : "/onboarding", { + const params = new URLSearchParams(location.search); + const next = params.get("next"); + const safeNext = next && next.startsWith("/") ? next : null; + navigate(safeNext || (profileComplete ? "/dashboard" : "/onboarding"), { replace: true, }); } - }, [user, loading, profileComplete, navigate]); + }, [user, loading, profileComplete, navigate, location.search]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault();