Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

refactor(frontend/auth): Move `/copilot` auth check to middleware (#12053)

Reinier van der Leer52650eed1d97
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts
index c480ce13b9..3dbba6e790 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts
@@ -3,7 +3,6 @@ import { useBreakpoint } from "@/lib/hooks/useBreakpoint";
import { useSupabase } from "@/lib/supabase/hooks/useSupabase";
import { useChat } from "@ai-sdk/react";
import { DefaultChatTransport } from "ai";
-import { useRouter } from "next/navigation";
import { useEffect, useMemo, useState } from "react";
import { useChatSession } from "./useChatSession";
@@ -11,7 +10,6 @@ export function useCopilotPage() {
const { isUserLoading, isLoggedIn } = useSupabase();
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
const [pendingMessage, setPendingMessage] = useState<string | null>(null);
- const router = useRouter();
const {
sessionId,
@@ -54,10 +52,6 @@ export function useCopilotPage() {
transport: transport ?? undefined,
});
- useEffect(() => {
- if (!isUserLoading && !isLoggedIn) router.replace("/login");
- }, [isUserLoading, isLoggedIn]);
-
useEffect(() => {
if (!hydratedMessages || hydratedMessages.length === 0) return;
setMessages((prev) => {
diff --git a/autogpt_platform/frontend/src/lib/supabase/helpers.ts b/autogpt_platform/frontend/src/lib/supabase/helpers.ts
index 26f7711bde..c77e43e7b4 100644
--- a/autogpt_platform/frontend/src/lib/supabase/helpers.ts
+++ b/autogpt_platform/frontend/src/lib/supabase/helpers.ts
@@ -6,6 +6,7 @@ import { SupabaseClient } from "@supabase/supabase-js";
export const PROTECTED_PAGES = [
"/auth/authorize",
"/auth/integrations",
+ "/copilot",
"/monitor",
"/build",
"/onboarding",