我使用 NextAuth.js 进行 Next.js 身份验证。登录工作正常,但页面仍然以错误的凭据重新加载。它没有显示任何错误。我需要处理错误以显示某种 toast 消息。
signIn("credentials", {
...values,
redirect: false,
})
.then(async () => {
await router.push("/dashboard");
})
.catch((e) => {
toast("Credentials do not match!", { type: "error" });
});
Run Code Online (Sandbox Code Playgroud)