Client_fetch_error会话ConnRejected(下一个身份验证v3)



首先,我试图在本地机器上运行生产构建,这就是为什么我仍然使用localhost:3000作为下一个url。我在终端中收到以下错误:https://next-auth.js.org/errors#client_fetch_errorsession FetchError:请求http://localhost:3000/api/auth/session失败,原因:连接ECONNREFUSED::1:3000

因此,当我在开发模式下运行时,它只为会话提供了一个被拒绝的连接。代码正常工作,会话被创建。这是我的[…nexttauth].js api页面。

import NextAuth from "next-auth";
import Providers from "next-auth/providers";
import { connectDatabase } from "../../../helpers/db-util";
import { verifyPasswd } from "../../../helpers/api-util";
export default NextAuth({
session: {
jwt: true,
},
providers: [
Providers.Credentials({
async authorize(credentials) {
const client = await connectDatabase();
const usersCollection = client.db().collection("members");


const user = await usersCollection.findOne({
memberId: credentials.memberNumber
});
console.log(user)
if (!user) {
client.close();
throw new Error("No User Found");
}
const isValid = await verifyPasswd(credentials.password, user.password);
if (!isValid) {
client.close();
throw new Error("Invalid Password");
}
client.close();
// =================================================================
// I might have to store the data for the token above the client.close() method
// if so will store an object.
//================================================================
return {
name: user.memberId,
email: user.email

};
},
}),
],
});

连接到mongo数据库以查找用户工作正常。真的需要一些帮助。

要解决此问题,请向我们展示您的连接数据库代码,特别是url。如果你有docker,你应该用你的容器名称解析url。我与next也有连接问题,但在服务器端呈现时

最新更新