From 742c24fa6bb64add186b45cb593c0cc89ee45489 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Thu, 26 Mar 2026 22:21:59 +0100 Subject: [PATCH] fix: prevent auth flash on checkout, skip subscription guard on success return --- app/checkout/page.tsx | 5 +++-- app/layout-content.tsx | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/checkout/page.tsx b/app/checkout/page.tsx index 320eaf9..d93e67f 100644 --- a/app/checkout/page.tsx +++ b/app/checkout/page.tsx @@ -136,12 +136,13 @@ function CheckoutContent() { } }, [authLoading, user, router]) - // -- Subscription guard -- + // -- Subscription guard (skip on success page — it handles its own redirect) -- useEffect(() => { + if (status === 'success') return if (subscription && (subscription.subscription_status === 'active' || subscription.subscription_status === 'trialing')) { router.replace('/') } - }, [subscription, router]) + }, [subscription, status, router]) // -- Param validation -- useEffect(() => { diff --git a/app/layout-content.tsx b/app/layout-content.tsx index 42fc2ea..ddf2ccf 100644 --- a/app/layout-content.tsx +++ b/app/layout-content.tsx @@ -98,8 +98,8 @@ function LayoutInner({ children }: { children: React.ReactNode }) { return } - // While auth is loading on a site page, render nothing to prevent flash of public header - if (auth.loading && isSitePage) { + // While auth is loading on a site or checkout page, render nothing to prevent flash of public header + if (auth.loading && (isSitePage || isCheckoutPage)) { return null }