Next Auth error: 405 (Method Not Allowed)

Looks like NextAuth has an issue with NextJS14 and SRC project instead of Pages.
Deleting and recreating […nextauth] did not work, and probably I would be worried if it did…

What happened in my case was that I had to encapsulate the NextAuth into the proper requests.

Step 1 :
route.js

const myNextAuthOptions = {} // Your options here…

export async function GET( req,res ) {
return NextAuth(req,res,MyNextAuthOption)
}

export async function POST( req,res ) {
return NextAuth(req,res,MyNextAuthOption)
}

New Error :
Yay, you are almost there. In my case NextJS gave me a different error, complaining that
my ./core/routes were not exported on the package.json from NextAuth…

Step 2 :
edit node_modules/next-auth/package.json
Add :
“./core/routes”: {
“types”: “./core/routes/.d.ts",
“default”: "./core/routes/
.js”
}
to “exports”

This fixed for me. Hope it could help you.