From dfebb544cfee180dc8bc9ecec65658f1eaa332ff Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 27 Sep 2025 20:45:10 +0000 Subject: [PATCH] Avoid redirect loop: wait for auth to resolve before redirecting from Dashboard cgen-4ecde8665964461e8ddcaaf052e7b577 --- client/pages/Dashboard.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/client/pages/Dashboard.tsx b/client/pages/Dashboard.tsx index 6f9e784c..8d586670 100644 --- a/client/pages/Dashboard.tsx +++ b/client/pages/Dashboard.tsx @@ -57,14 +57,20 @@ export default function Dashboard() { useEffect(() => { console.log("Dashboard useEffect:", { user: !!user, profile: !!profile, authLoading }); - // Force redirect immediately if no user - if (!user) { - console.log("No user, redirecting to login"); + // Only redirect to login when auth is resolved and there's no user + if (!user && !authLoading) { + console.log("No user after auth resolved, redirecting to login"); setIsLoading(false); navigate("/login", { replace: true }); return; } + // While auth is still resolving, keep showing loading state + if (!user && authLoading) { + setIsLoading(true); + return; + } + if (user && profile) { console.log("User and profile exist, loading dashboard data"); loadDashboardData();