gpt4 book ai didi

reactjs - 如何在下一个js中使用auth0登录?

转载 作者:行者123 更新时间:2023-12-05 01:29:02 24 4
gpt4 key购买 nike

如何使用 auth0 登录下一个 js 应用程序?我按照 auth0 网站上的快速入门进行操作,但在登录页面上收到此错误。

<a href="/api/auth/login">Login</a>

这是 pages/api/[...auth0].js

import { handleAuth } from '@auth0/nextjs-auth0';

export default handleAuth();

我在登录页面上收到此错误。

error on login

我在我的终端里得到了这个

OPError: expected 200 OK, got: 404 Not Found
at processResponse (/home/madhav/Documents/Web Development/freelancing/frontend-affilboost/node_modules/openid-client/lib/helpers/process_response.js:48:11)
at Function.discover (/home/madhav/Documents/Web Development/freelancing/frontend-affilboost/node_modules/openid-client/lib/issuer.js:252:22)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
error: 'expected 200 OK, got: 404 Not Found'
}

我得到 Failed to load resource, the server responded with code 500在我浏览器的控制台中。

我做错了什么?

最佳答案

您可能遇到的问题如下:

  1. 在你的 .env.local 文件中 AUTH0_BASE_URL应设置为 http://localhost:<port>
  2. 在你的 .env.local 文件中 AUTH0_ISSUER_BASE_URL应设置为您的 Auth0 域:https://xxx.us.auth0.com
  3. 确保您在 Auth0 中的回调 URL 设置为 http://localhost:<port>/api/auth/callback

替换<port>使用您在本地使用的任何端口来为应用程序提供服务。

关于reactjs - 如何在下一个js中使用auth0登录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68077781/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com