Tweak route
This commit is contained in:
parent
8b47fbd9e4
commit
8459ac8c63
1 changed files with 2 additions and 3 deletions
|
|
@ -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 })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue