nextauth req.auth in route handler always null (app router)
Unanswered
Long-horned bees posted this in #help-forum
Long-horned beesOP
I am using nextjs 14 nextauth 5beta and i got the setup auth.config.ts and auth.ts
inside auth.confg.ts i have a callbacks array with autorized that i am calling a router handler from with fetch(). Inside the routehandler i am testing that i can get aut information, so it looks something like this:
export const GET = auth(async (req) => {
const auth = await req.auth
console.log(auth, 'auth in handler')
}
the middleware is something like this:
import authConfig from './auth.config'
import NextAuth from 'next-auth'
const { auth: middleware } = NextAuth(authConfig)
becuase of edge workaround in being able to use TableClient in auth.ts
Any idea how i can get req.auth in the handler to not be null?
inside auth.confg.ts i have a callbacks array with autorized that i am calling a router handler from with fetch(). Inside the routehandler i am testing that i can get aut information, so it looks something like this:
export const GET = auth(async (req) => {
const auth = await req.auth
console.log(auth, 'auth in handler')
}
the middleware is something like this:
import authConfig from './auth.config'
import NextAuth from 'next-auth'
const { auth: middleware } = NextAuth(authConfig)
becuase of edge workaround in being able to use TableClient in auth.ts
Any idea how i can get req.auth in the handler to not be null?