Skip to content
Snippets Groups Projects
route.ts 489 B
Newer Older
Omar Kasbah's avatar
Omar Kasbah committed
import { getServerSession } from 'next-auth/next'
import { NextResponse } from 'next/server'
import { authOptions } from './auth/[...nextauth]/route'

export async function GET(request: Request) {
    const session = await getServerSession(authOptions)

    if (!session) {
        return new NextResponse(JSON.stringify({ error: 'unauthorized' }), {
            status: 401
        })
    }

    console.log('GET API', session)
    return NextResponse.json({ authenticated: !!session })
}