Next-Auth getSession 在我的开发环境中返回 null

Sin*_*hin 6 next.js next-auth

我在其中一个页面中使用以下代码:

export async function getServerSideProps(context) {
  const session = await getSession(context)
  return {
    props: { session }
  }
}
Run Code Online (Sandbox Code Playgroud)

并且会话返回空值。我收到以下错误:

[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
Run Code Online (Sandbox Code Playgroud)

如果我尝试在浏览器中导航到http://localhost:3000/api/auth/session,我会正常获取会话对象。此外,我的同事在他的机器上有相同的代码,对他来说工作正常。

我知道我的环境和他的环境之间的唯一区别是我使用的是 windows 而他使用的是 mac。不确定这是否会导致这里出现问题。

asi*_*hej 1

尝试删除.next根目录中的文件夹并重试