From 8459ac8c6322a1d2986409c3fe4b2dc1dc25a4b7 Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Fri, 16 Jun 2023 16:35:27 -0400 Subject: [PATCH] Tweak route --- app/api/chat/route.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index 5500723..338210d 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -4,16 +4,15 @@ import { Configuration, OpenAIApi } from 'openai-edge' import { auth } from '@/auth' import { nanoid } from '@/lib/utils' -import { Session } from 'inspector' export const runtime = 'edge' export async function POST(req: Request) { const json = await req.json() const { messages, previewToken } = json - let session: Session + const session = await auth() + if (process.env.VERCEL_ENV !== 'preview') { - session = await auth() if (session == null) { return new Response('Unauthorized', { status: 401 }) }