小编scx*_*992的帖子

getServerSideProps 中的 nextjs 和 next-auth getSession() 与 HTTPS 不起作用

我无法在 getServerSideProps 中使用 HTTPS 的 getSession() 。

\n

这正常吗?我尝试了很多次。

\n

如果使用 HTTPS 我会得到它。我无法在 getServerSideProps 中使用 getSession()

\n
__Secure-next-auth.callback-url\n__Secure-next-auth.session-token\n__Host-next-auth.csrf-toke\n
Run Code Online (Sandbox Code Playgroud)\n

如果使用 HTTP 并且我可以在 getServerSideProps 中 getSession() 就可以了

\n
next-auth.callback-url\nnext-auth.session-token\nnext-auth.csrf-token\n
Run Code Online (Sandbox Code Playgroud)\n

如何在 getServerSideProps 中的 HTTPS getSession() 上修复它?

\n

我在 http 或 https 上运行相同的代码进行测试

\n

如果使用 http 运行,我可以获得 props.session\n 如果使用https运行,我无法获取 props.session

\n
import { getSession } from 'next-auth/client';\n\nexport default function Home(props) {\n  console.log(props.session);\n  return (\n    <div>\n      <h1>Server Side Rendering</h1>\n    </div>\n  );\n}\nexport async function getServerSideProps(context) {\n  return {\n    props: {\n      session: await …
Run Code Online (Sandbox Code Playgroud)

reactjs next.js next-auth

12
推荐指数
1
解决办法
7万
查看次数

标签 统计

next-auth ×1

next.js ×1

reactjs ×1