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

ang*_*elo 3 reactjs auth0 next.js

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

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

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

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

export default handleAuth();

Run Code Online (Sandbox Code Playgroud)

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

登录时出错

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

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'
}

Run Code Online (Sandbox Code Playgroud)

我正在Failed to load resource, the server responded with code 500进入浏览器的控制台。

我究竟做错了什么?

Noa*_*vis 5

您在这里可能遇到的问题如下:

  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>为您在本地使用的为应用程序提供服务的任何端口。