我有一个 Next.js 应用程序,它使用 AWS Cognito 用户池进行身份验证。我有一个自定义 UI,并在我的代码中使用aws-amplify直接调用signIn/ signOut/etc... 的包。(我之前使用过 AWS 托管 UI,并且遇到了下面列出的相同问题 - 我希望切换并深入研究能够揭示我的问题的实际 API,但事实并非如此)
开发中的所有内容(在本地主机上运行)都工作正常 - 我可以使用以下命令在页面的渲染函数中登录并访问当前会话
import { Auth } from 'aws-amplify';
...
export default const MyPage = (props) => {
useEffect(async () => {
const session = await Auth.currentSession();
...
}
...
}
Run Code Online (Sandbox Code Playgroud)
以及SSR期间
import { withSSRContext } from 'aws-amplify';
...
export async function getServerSideProps(context) {
...
const SSR = withSSRContext(context);
const session = await SSR.Auth.currentSession();
...
}
Run Code Online (Sandbox Code Playgroud)
但是,当我部署到运行临时环境的 AWS Amplify 时,在 …