Skip to content

Commit 4cff50f

Browse files
committed
fix(chat): guard the chat page prefetch behind the chat flag
1 parent db13084 commit 4cff50f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/chat/[chatId]

apps/sim/app/workspace/[workspaceId]/chat/[chatId]/page.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { Suspense } from 'react'
22
import { dehydrate, HydrationBoundary } from '@tanstack/react-query'
33
import type { Metadata } from 'next'
4+
import { notFound } from 'next/navigation'
45
import { getSession } from '@/lib/auth'
6+
import { isChatEnabled } from '@/lib/core/config/env-flags'
57
import { getQueryClient } from '@/app/_shell/providers/get-query-client'
68
import { Home } from '@/app/workspace/[workspaceId]/home/home'
79
import { HomeFallback } from '@/app/workspace/[workspaceId]/home/home-fallback'
@@ -20,6 +22,12 @@ interface ChatPageProps {
2022
}
2123

2224
export default async function ChatPage({ params }: ChatPageProps) {
25+
// The layout 404s too, but pages and layouts resolve concurrently — without this
26+
// the prefetch below still fires on its way out.
27+
if (!isChatEnabled) {
28+
notFound()
29+
}
30+
2331
const [{ workspaceId, chatId }, session] = await Promise.all([params, getSession()])
2432
const userId = session?.user?.id
2533
const queryClient = getQueryClient()

0 commit comments

Comments
 (0)