Fix NextAuth v4 imports and exports

This commit is contained in:
2025-12-02 14:01:05 +00:00
parent 40b168b6d8
commit 2f7bc4fe8e
2 changed files with 7 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from 'next/server'
import { prisma } from '@/lib/db'
import { auth } from '@/auth'
import { getServerSession } from 'next-auth'
import { authOptions } from '@/pages/api/auth/[...nextauth]'
export const dynamic = 'force-dynamic'
export const revalidate = 0
@@ -10,7 +11,7 @@ export async function GET(
{ params }: { params: { id: string } }
) {
try {
const session = await auth()
const session = await getServerSession(authOptions)
if (!session?.user?.id) {
return NextResponse.json(
{ error: 'Unauthorized' },

View File

@@ -9,7 +9,7 @@ const loginSchema = z.object({
password: z.string().min(1),
})
export default NextAuth({
export const authOptions = {
providers: [
CredentialsProvider({
name: "credentials",
@@ -49,4 +49,6 @@ export default NextAuth({
return session
},
},
})
}
export default NextAuth(authOptions)