在Firebase上部署NextAuth

ubof19bj  于 2023-04-30  发布在  其他
关注(0)|答案(1)|浏览(112)

我刚刚在firebase上部署了一个带有NextAuth的NextJs应用程序(https://firebase.google.com/docs/hosting/frameworks/nextjs
我在浏览器控制台中遇到错误。ext-auth][error][CLIENT_FETCH_ERROR] https://next-auth.js.org/errors#client_fetch_error
根据文档,当未设置env var NEXTAUTH_URL时,会出现此错误。但我把它设置在我的。env.production.
当我尝试登录时,我有这个错误:
Error: Forbidden Your client does not have permission to get URL /api/auth/error from this server.
NextAuth:使用jwt策略的凭据(jwt由我的后端发送,NEXT_PUBLIC_API见下文)
我的.env.production看起来像这样:
NEXT_PUBLIC_API=http://BACKEND-IP:PORT
NEXTAUTH_URL=https://my-app-name-her.web.app
NEXTAUTH_SECRET=long-secret-here
我错过了什么?非常感谢

kgsdhlau

kgsdhlau1#

根据错误,这可能是解决方案。
我想你需要在Google Developer Console的**“Authorized redirect URI”中添加域名。https://console.developers.google.com/apis/credentials
根据NextAuth文档, www.example.com
创建凭证时使用的
授权重定向URI**必须包含您的全域,并以回调路径结束。比如说;

  • 对于生产:https://{YOUR_DOMAIN}/api/auth/callback/google
  • 发展方面:http://localhost:3000/api/auth/callback/google

相关问题