The code is exactly the same as your repo code. Please let me know if this is because of next-auth beta version.
Bassir Unselected an answer February 7, 2024
The issue is because of some updates on next and nextauth package.
How to fix it:
-
Install next canary or wait for [email protected] to fix the issue https://github.com/vercel/next.js/pull/61721
$ npm i [email protected]
-
reinstall next-auth@beta
$ npm uninstall next-auth@beta
$ npm install next-auth@beta -
remove AUTH_URL in .env:
# AUTH_URL=http://localhost:3000
-
add ._doc in jwt function in auth.ts
callbacks: { async jwt({ user, trigger, session, token }: any) { if (user) { token.user = { _id: user._doc._id, email: user._doc.email, name: user._doc.name, isAdmin: user._doc.isAdmin, } } ...
Bassir Edited answer February 8, 2024