Next-Auth:无法读取未定义的 属性 'Adapter'
Next-Auth: Cannot read property 'Adapter' of undefined
当我在 vercel.in 开发模式下部署 nextjs 应用程序时出现此错误一切正常但是当我在 vercel 中部署我的应用程序时出现此错误。
这个错误可能来自 next-auth,但我不知道为什么会出现。
我在 [...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);
}
}
})
]});
当请求 /api/auth/session 和 /api/auth/_log
时会出现此错误
我很高兴有人能帮助我。
您使用的是哪个版本的 next-auth?如果是 3.20.0 及更高版本,则问题与适配器有关。尝试检查部署时您的函数日志中是否有类似这样的内容:
如果是这样,请在将 next-auth
更新到最新版本后尝试卸载 @types/next-auth
。它为我解决了这个问题。
当我在 vercel.in 开发模式下部署 nextjs 应用程序时出现此错误一切正常但是当我在 vercel 中部署我的应用程序时出现此错误。
这个错误可能来自 next-auth,但我不知道为什么会出现。
我在 [...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);
}
}
})
]});
当请求 /api/auth/session 和 /api/auth/_log
时会出现此错误我很高兴有人能帮助我。
您使用的是哪个版本的 next-auth?如果是 3.20.0 及更高版本,则问题与适配器有关。尝试检查部署时您的函数日志中是否有类似这样的内容:
如果是这样,请在将 next-auth
更新到最新版本后尝试卸载 @types/next-auth
。它为我解决了这个问题。