From bee5be3b749746a5dd26c96baa3da4cd40abe627 Mon Sep 17 00:00:00 2001 From: Otto Date: Fri, 30 Jan 2026 05:23:24 +0000 Subject: [PATCH] fix(frontend): remove double flag check on homepage redirect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root page now always redirects to /copilot, which then handles the feature flag check via FeatureFlagPage in its layout. This eliminates the race condition where: 1. / checks flag → goes to /copilot 2. /copilot layout checks flag again → race condition with LD init With single check point, we avoid the double-check race that caused users to be redirected to /library on hard refresh. Fixes: SECRT-1845 --- autogpt_platform/frontend/src/app/page.tsx | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/autogpt_platform/frontend/src/app/page.tsx b/autogpt_platform/frontend/src/app/page.tsx index 31d1e96e48..9a55e986bc 100644 --- a/autogpt_platform/frontend/src/app/page.tsx +++ b/autogpt_platform/frontend/src/app/page.tsx @@ -1,14 +1,20 @@ "use client"; -import { FeatureFlagRedirect } from "@/services/feature-flags/FeatureFlagRedirect"; -import { Flag } from "@/services/feature-flags/use-get-flag"; +import { useRouter } from "next/navigation"; +import { useEffect } from "react"; +/** + * Root page always redirects to /copilot. + * The /copilot page handles the feature flag check and redirects to /library if needed. + * This single-check approach avoids race conditions with LaunchDarkly initialization. + * See: SECRT-1845 + */ export default function Page() { - return ( - - ); + const router = useRouter(); + + useEffect(() => { + router.replace("/copilot"); + }, [router]); + + return null; }