Skip to content

Commit

Permalink
Fix Agents Page Crash (#946)
Browse files Browse the repository at this point in the history
* fix: add /agents pages back to middleware.ts

* fix: replace createRouteHandlerClient with createServerComponentClient in server components
  • Loading branch information
elisalimli authored Apr 9, 2024
1 parent 9b35c28 commit 3447144
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 22 deletions.
4 changes: 2 additions & 2 deletions libs/ui/app/agents/[agentId]/page.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions libs/ui/app/agents/page.tsx
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions libs/ui/app/integrations/page.tsx
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
4 changes: 2 additions & 2 deletions libs/ui/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions libs/ui/app/logs/page.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions libs/ui/app/settings/api-keys/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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 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()
Expand Down
4 changes: 2 additions & 2 deletions libs/ui/app/settings/billing/page.tsx
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
4 changes: 2 additions & 2 deletions libs/ui/app/settings/layout.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
Expand Down
7 changes: 5 additions & 2 deletions libs/ui/app/settings/page.tsx
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
4 changes: 2 additions & 2 deletions libs/ui/app/workflows/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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 },
Expand Down
4 changes: 2 additions & 2 deletions libs/ui/app/workflows/page.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions libs/ui/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const config = {
"/logs/:path*",
"/settings/:path*",
"/integrations/:path*",
"/agents/:path*",
"/workflows/:path*",
"/onboarding",
],
Expand Down

0 comments on commit 3447144

Please sign in to comment.