Next.js Discord

Discord Forum

Nextauth V5-beta: Getting session in req.auth API handler with call from signin callback

Unanswered
Long-horned bees posted this in #help-forum
Open in Discord
Long-horned beesOP
I am trying to call a api route from the signin callback to do some aditional authorization in a database call. Because of edge-runtime/version with azure TableClient i cant do that directly in the signin callback so i created a API route. But im i right in that its not possible to get the session from api route when called from the signin callback, maybe its not set yet?


export const GET = auth(async (req: Request) => {
const session = (await req.auth) as Session | null
}

req.auth is null when called from the signin callback it looks like.

Can i set something in the signin callback so that its accesseble in the api?

0 Replies