From 344714467d0ace4edd7da9f517e4c1e789ead3d9 Mon Sep 17 00:00:00 2001 From: Ali Salimli <67149699+elisalimli@users.noreply.github.com> Date: Tue, 9 Apr 2024 23:55:23 +0400 Subject: [PATCH] Fix Agents Page Crash (#946) * fix: add /agents pages back to middleware.ts * fix: replace createRouteHandlerClient with createServerComponentClient in server components --- libs/ui/app/agents/[agentId]/page.tsx | 4 ++-- libs/ui/app/agents/page.tsx | 4 ++-- libs/ui/app/integrations/page.tsx | 4 ++-- libs/ui/app/layout.tsx | 4 ++-- libs/ui/app/logs/page.tsx | 4 ++-- libs/ui/app/settings/api-keys/page.tsx | 4 ++-- libs/ui/app/settings/billing/page.tsx | 4 ++-- libs/ui/app/settings/layout.tsx | 4 ++-- libs/ui/app/settings/page.tsx | 7 +++++-- libs/ui/app/workflows/[id]/page.tsx | 4 ++-- libs/ui/app/workflows/page.tsx | 4 ++-- libs/ui/middleware.ts | 1 + 12 files changed, 26 insertions(+), 22 deletions(-) diff --git a/libs/ui/app/agents/[agentId]/page.tsx b/libs/ui/app/agents/[agentId]/page.tsx index 4ec62dbcc..2025b642b 100644 --- a/libs/ui/app/agents/[agentId]/page.tsx +++ b/libs/ui/app/agents/[agentId]/page.tsx @@ -1,6 +1,6 @@ import { cookies } from "next/headers" import Link from "next/link" -import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs" +import { createServerComponentClient } from "@supabase/auth-helpers-nextjs" import { TbBrandOpenai } from "react-icons/tb" import { Api } from "@/lib/api" @@ -12,7 +12,7 @@ import Settings from "./settings" export const dynamic = "force-dynamic" export default async function AgentPage({ params }: { params: any }) { const { agentId } = params - const supabase = createRouteHandlerClient({ cookies }) + const supabase = createServerComponentClient({ cookies }) const { data: { user }, } = await supabase.auth.getUser() diff --git a/libs/ui/app/agents/page.tsx b/libs/ui/app/agents/page.tsx index be254e133..c6b2a9481 100644 --- a/libs/ui/app/agents/page.tsx +++ b/libs/ui/app/agents/page.tsx @@ -1,5 +1,5 @@ import { cookies } from "next/headers" -import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs" +import { createServerComponentClient } from "@supabase/auth-helpers-nextjs" import { Api } from "@/lib/api" @@ -17,7 +17,7 @@ export default async function Agents({ take: string } }) { - const supabase = createRouteHandlerClient({ cookies }) + const supabase = createServerComponentClient({ cookies }) const { data: { user }, } = await supabase.auth.getUser() diff --git a/libs/ui/app/integrations/page.tsx b/libs/ui/app/integrations/page.tsx index 52f462813..5c5511126 100644 --- a/libs/ui/app/integrations/page.tsx +++ b/libs/ui/app/integrations/page.tsx @@ -1,12 +1,12 @@ import { cookies } from "next/headers" -import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs" +import { createServerComponentClient } from "@supabase/auth-helpers-nextjs" import { Api } from "@/lib/api" import IntegrationsClientPage from "./client-page" export default async function Integration() { - const supabase = createRouteHandlerClient({ cookies }) + const supabase = createServerComponentClient({ cookies }) const { data: { user }, } = await supabase.auth.getUser() diff --git a/libs/ui/app/layout.tsx b/libs/ui/app/layout.tsx index 33be4d4d1..5c6ef92c6 100644 --- a/libs/ui/app/layout.tsx +++ b/libs/ui/app/layout.tsx @@ -2,7 +2,7 @@ import "@/styles/globals.css" import { Metadata } from "next" import { cookies } from "next/headers" -import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs" +import { createServerComponentClient } from "@supabase/auth-helpers-nextjs" import { siteConfig } from "@/config/site" import { fontSans } from "@/lib/fonts" @@ -37,7 +37,7 @@ interface RootLayoutProps { export const dynamic = "force-dynamic" export default async function RootLayout({ children }: RootLayoutProps) { - const supabase = createRouteHandlerClient({ cookies }) + const supabase = createServerComponentClient({ cookies }) if (process.env.NEXT_PUBLIC_POSTHOG_KEY) { PostHogClient() diff --git a/libs/ui/app/logs/page.tsx b/libs/ui/app/logs/page.tsx index d84447433..91c2e2208 100644 --- a/libs/ui/app/logs/page.tsx +++ b/libs/ui/app/logs/page.tsx @@ -1,5 +1,5 @@ import { cookies } from "next/headers" -import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs" +import { createServerComponentClient } from "@supabase/auth-helpers-nextjs" import { TbTerminal2 } from "react-icons/tb" import { Api } from "@/lib/api" @@ -14,7 +14,7 @@ export default async function Agents({ } }) { let agent = "" - const supabase = createRouteHandlerClient({ cookies }) + const supabase = createServerComponentClient({ cookies }) const { data: { user }, } = await supabase.auth.getUser() diff --git a/libs/ui/app/settings/api-keys/page.tsx b/libs/ui/app/settings/api-keys/page.tsx index 8c0ee01a9..0090ca99c 100644 --- a/libs/ui/app/settings/api-keys/page.tsx +++ b/libs/ui/app/settings/api-keys/page.tsx @@ -1,5 +1,5 @@ import { cookies } from "next/headers" -import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs" +import { createServerComponentClient } from "@supabase/auth-helpers-nextjs" import { Api } from "@/lib/api" @@ -7,7 +7,7 @@ import ApiKeysTable from "./api-keys" import { CreateSecretKey } from "./create-api-key" export default async function Settings() { - const supabase = createRouteHandlerClient({ cookies }) + const supabase = createServerComponentClient({ cookies }) const { data: { user }, } = await supabase.auth.getUser() diff --git a/libs/ui/app/settings/billing/page.tsx b/libs/ui/app/settings/billing/page.tsx index 9ee513176..cd4aec4ac 100644 --- a/libs/ui/app/settings/billing/page.tsx +++ b/libs/ui/app/settings/billing/page.tsx @@ -1,10 +1,10 @@ import { cookies } from "next/headers" -import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs" +import { createServerComponentClient } from "@supabase/auth-helpers-nextjs" import PricingTable from "@/app/settings/billing/pricing-table" export default async function Billing() { - const supabase = createRouteHandlerClient({ cookies }) + const supabase = createServerComponentClient({ cookies }) const { data: { user }, } = await supabase.auth.getUser() diff --git a/libs/ui/app/settings/layout.tsx b/libs/ui/app/settings/layout.tsx index 3da8990ca..e41ec98eb 100644 --- a/libs/ui/app/settings/layout.tsx +++ b/libs/ui/app/settings/layout.tsx @@ -1,5 +1,5 @@ import { cookies } from "next/headers" -import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs" +import { createServerComponentClient } from "@supabase/auth-helpers-nextjs" import { siteConfig } from "@/config/site" import { SettingsSidebar } from "@/components/account-sidebar" @@ -11,7 +11,7 @@ interface SettingsLayoutProps { export default async function SettingsLayout({ children, }: SettingsLayoutProps) { - const supabase = createRouteHandlerClient({ cookies }) + const supabase = createServerComponentClient({ cookies }) const { data: { user }, } = await supabase.auth.getUser() diff --git a/libs/ui/app/settings/page.tsx b/libs/ui/app/settings/page.tsx index 02c82adbd..ce5975e71 100644 --- a/libs/ui/app/settings/page.tsx +++ b/libs/ui/app/settings/page.tsx @@ -1,12 +1,15 @@ import { cookies } from "next/headers" -import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs" +import { + createRouteHandlerClient, + createServerComponentClient, +} from "@supabase/auth-helpers-nextjs" import SettingsClientPage from "./client-page" export const dynamic = "force-dynamic" export default async function Settings() { - const supabase = createRouteHandlerClient({ cookies }) + const supabase = createServerComponentClient({ cookies }) const { data: { user }, } = await supabase.auth.getUser() diff --git a/libs/ui/app/workflows/[id]/page.tsx b/libs/ui/app/workflows/[id]/page.tsx index fcd41b2f0..4fb07779c 100644 --- a/libs/ui/app/workflows/[id]/page.tsx +++ b/libs/ui/app/workflows/[id]/page.tsx @@ -1,5 +1,5 @@ import { cookies } from "next/headers" -import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs" +import { createServerComponentClient } from "@supabase/auth-helpers-nextjs" import { Api } from "@/lib/api" @@ -10,7 +10,7 @@ export default async function Assistant({ }: { params: { id: string } }) { - const supabase = createRouteHandlerClient({ cookies }) + const supabase = createServerComponentClient({ cookies }) const { id } = params const { data: { user }, diff --git a/libs/ui/app/workflows/page.tsx b/libs/ui/app/workflows/page.tsx index 7be081d63..0a9cdb7c5 100644 --- a/libs/ui/app/workflows/page.tsx +++ b/libs/ui/app/workflows/page.tsx @@ -1,5 +1,5 @@ import { cookies } from "next/headers" -import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs" +import { createServerComponentClient } from "@supabase/auth-helpers-nextjs" import Stripe from "stripe" import { Api } from "@/lib/api" @@ -16,7 +16,7 @@ export default async function Workflows({ }: { searchParams: { checkout_session_id: string } }) { - const supabase = createRouteHandlerClient({ cookies }) + const supabase = createServerComponentClient({ cookies }) const { data: { user }, } = await supabase.auth.getUser() diff --git a/libs/ui/middleware.ts b/libs/ui/middleware.ts index b7872a941..04f1703e2 100644 --- a/libs/ui/middleware.ts +++ b/libs/ui/middleware.ts @@ -47,6 +47,7 @@ export const config = { "/logs/:path*", "/settings/:path*", "/integrations/:path*", + "/agents/:path*", "/workflows/:path*", "/onboarding", ],