Tweak route

This commit is contained in:
Jared Palmer 2023-06-16 16:35:27 -04:00
parent 8b47fbd9e4
commit 8459ac8c63

View file

@ -4,16 +4,15 @@ import { Configuration, OpenAIApi } from 'openai-edge'
import { auth } from '@/auth' import { auth } from '@/auth'
import { nanoid } from '@/lib/utils' import { nanoid } from '@/lib/utils'
import { Session } from 'inspector'
export const runtime = 'edge' export const runtime = 'edge'
export async function POST(req: Request) { export async function POST(req: Request) {
const json = await req.json() const json = await req.json()
const { messages, previewToken } = json const { messages, previewToken } = json
let session: Session const session = await auth()
if (process.env.VERCEL_ENV !== 'preview') { if (process.env.VERCEL_ENV !== 'preview') {
session = await auth()
if (session == null) { if (session == null) {
return new Response('Unauthorized', { status: 401 }) return new Response('Unauthorized', { status: 401 })
} }