我在我的一个页面中使用以下代码:
export async function getServerSideProps(context) {
const session = await getSession(context)
return {
props: { session }
}
}
并且会话返回 null。我收到以下错误:
[next-auth][error][client_fetch_error] [
'http://localhost:3000/api/auth/session',
FetchError: request to http://localhost:3000/api/auth/session failed, reason: read ECONNRESET
如果我尝试在浏览器中导航到http://localhost:3000/api/auth/session我会正常获取会话对象。此外,我的同事在他的机器上有相同的代码,并且对他来说工作正常。
我知道我的环境和他的环境之间的唯一区别是我使用的是 windows 而他使用的是 mac。不确定这是否会导致这里出现问题。