From 5f60a8ab35aaa2b87de2a6288c6885e811e8556c Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Mon, 22 May 2023 10:21:51 -0400 Subject: [PATCH] Authenticate /api/generate --- app/api/generate/route.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/api/generate/route.ts b/app/api/generate/route.ts index 7d34526..3ca36fb 100644 --- a/app/api/generate/route.ts +++ b/app/api/generate/route.ts @@ -1,10 +1,12 @@ +import { auth } from "@/auth"; import { OpenAIStream, openai } from "@/lib/openai"; -import { getServerSession } from "@/lib/session/get-server-session"; import { prisma } from "@/lib/prisma"; -export async function POST(req: Request) { +export const runtime = "edge"; + +export const POST = auth(async function POST(req: Request) { const json = await req.json(); - const session = await getServerSession(); + console.log(req.auth); const res = await openai.createChatCompletion({ model: "gpt-3.5-turbo", @@ -41,4 +43,4 @@ export async function POST(req: Request) { status: 200, headers: { "Content-Type": "text/event-stream" }, }); -} +});