mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-30 09:28:19 -05:00
fix(frontend): remove double flag check on homepage redirect
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
This commit is contained in:
@@ -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 (
|
||||
<FeatureFlagRedirect
|
||||
flag={Flag.CHAT}
|
||||
whenEnabled="/copilot"
|
||||
whenDisabled="/library"
|
||||
/>
|
||||
);
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
router.replace("/copilot");
|
||||
}, [router]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user