From 3b34c04a7a2c6685b449fbcff2bb939c48ac8623 Mon Sep 17 00:00:00 2001 From: Ubbe Date: Tue, 18 Nov 2025 16:41:51 +0700 Subject: [PATCH] fix(frontend): logout console issues (#11400) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Changes 🏗️ Fixed the logout errors by removing duplicate redirects. `serverLogout` was calling `redirect("/login")` (which throws `NEXT_REDIRECT`), and then `useSupabaseStore` was also calling `router.refresh()`, causing conflicts. Updated `serverLogout` to return a result object instead of redirecting, and moved the redirect to the client using `router.push("/login")` after logout completes. This removes the `NEXT_REDIRECT` error and ensures a single redirect. Screenshot 2025-11-18 at 16 14 54 Also addressed 401 errors during logout. Hooks like `useCredits` were still making API calls after logout, causing "Authorization header is missing" errors. Added a check in `_makeClientRequest` to detect logout-in-progress and suppress authentication errors during that window. This prevents console noise and avoids unnecessary error handling. Screenshot 2025-11-18 at 16 14 45 ## Checklist 📋 ### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Log out of your account - [x] There are no errors showing up on the browser devtools --- .../components/AccountLogoutOption.tsx | 5 +-- .../layout/Navbar/components/NavbarView.tsx | 6 ++-- .../src/lib/autogpt-server-api/client.ts | 34 ++++++++++++++----- .../src/lib/autogpt-server-api/helpers.ts | 10 +++--- .../frontend/src/lib/supabase/actions.ts | 12 ++++--- .../lib/supabase/hooks/useSupabaseStore.ts | 22 +++++------- 6 files changed, 50 insertions(+), 39 deletions(-) diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/AccountLogoutOption.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/AccountLogoutOption.tsx index 2e16a542db..c462e1c6ac 100644 --- a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/AccountLogoutOption.tsx +++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/AccountLogoutOption.tsx @@ -1,15 +1,13 @@ "use client"; import { IconLogOut } from "@/components/__legacy__/ui/icons"; import { LoadingSpinner } from "@/components/__legacy__/ui/loading"; +import { toast } from "@/components/molecules/Toast/use-toast"; import { useSupabase } from "@/lib/supabase/hooks/useSupabase"; import { cn } from "@/lib/utils"; import * as Sentry from "@sentry/nextjs"; -import { useRouter } from "next/navigation"; import { useTransition } from "react"; -import { toast } from "@/components/molecules/Toast/use-toast"; export function AccountLogoutOption() { - const router = useRouter(); const [isPending, startTransition] = useTransition(); const supabase = useSupabase(); @@ -17,7 +15,6 @@ export function AccountLogoutOption() { startTransition(async () => { try { await supabase.logOut(); - router.refresh(); } catch (e) { Sentry.captureException(e); toast({ diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/NavbarView.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/NavbarView.tsx index a0998a6016..ffe7d810b7 100644 --- a/autogpt_platform/frontend/src/components/layout/Navbar/components/NavbarView.tsx +++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/NavbarView.tsx @@ -1,10 +1,11 @@ "use client"; -import { useMemo } from "react"; import { useGetV2GetUserProfile } from "@/app/api/__generated__/endpoints/store/store"; import { IconAutoGPTLogo, IconType } from "@/components/__legacy__/ui/icons"; import { useBreakpoint } from "@/lib/hooks/useBreakpoint"; import { useSupabase } from "@/lib/supabase/hooks/useSupabase"; +import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag"; +import { useMemo } from "react"; import { getAccountMenuItems, loggedInLinks, loggedOutLinks } from "../helpers"; import { AccountMenu } from "./AccountMenu/AccountMenu"; import { AgentActivityDropdown } from "./AgentActivityDropdown/AgentActivityDropdown"; @@ -12,7 +13,6 @@ import { LoginButton } from "./LoginButton"; import { MobileNavBar } from "./MobileNavbar/MobileNavBar"; import { NavbarLink } from "./NavbarLink"; import { Wallet } from "./Wallet/Wallet"; -import { useGetFlag, Flag } from "@/services/feature-flags/use-get-flag"; interface NavbarViewProps { isLoggedIn: boolean; } @@ -41,7 +41,7 @@ export const NavbarView = ({ isLoggedIn }: NavbarViewProps) => {