I get this error when I deploy a nextjs app in vercel.in dev mode every thing works fine but when I deploy my app in vercel I got this error.
This error probably come from next-auth, but I don't no why this show up.
My code in [...nextauth].js:
export default NextAuth({
session: {
maxAge: 30 * 24 * 60 * 60,
jwt: true,
updateAge: 24 * 60 * 60
},
providers: [
Providers.Credentials({
async authorize(credentials) {
try {
await dbConnect();
const findUser = await User.findOne({ email: credentials.email });
if (!findUser) {
throw new Error('User not found.');
}
const comparePass = await comparePassword(credentials.password, findUser.password);
if (!comparePass) {
throw new Error('Confirm password not match.');
}
return { email: credentials.email, isAdmin: findUser.isAdmin };
} catch (error) {
throw new Error(error.message);
}
}
})
]});
This error will come when a request to /api/auth/session and /api/auth/_log
I'm glad for anyone can help me.
What version of next-auth are you on? If it's 3.20.0 and above then the problem has something to do with the adapters. Try to check if you get something like this on your Function logs upon deployment:
If so, try to uninstall @types/next-auth
once you have updated next-auth
to the latest version. It fixed this problem for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With