【问题标题】:Error: A valid Auth0 Client Secret must be provided on Vercel错误:必须在 Vercel 上提供有效的 Auth0 客户端密码
【发布时间】:2021-05-23 02:58:26
【问题描述】:

您好,我正在尝试在 vercel 上部署应用程序,在预览时一切正常,但是在生产中它失败并出现此错误。我正在使用@auth0/nextjs-auth0 版本^0.16.1

08:18:12.508    > Build error occurred
08:18:12.510    Error: A valid Auth0 Client Secret must be provided
08:18:12.510        at Object.createInstance [as default] (/vercel/workpath0/node_modules/@auth0/nextjs-auth0/dist/instance.node.js:16:15)
08:18:12.510        at initAuth0 (/vercel/workpath0/node_modules/@auth0/nextjs-auth0/dist/index.js:9:46)

auth0 配置文件,看起来和官方文档一样。

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

export default initAuth0({
  domain: process.env.AUTH0_DOMAIN,
  clientId: process.env.AUTH0_CLIENT_ID,
  clientSecret: process.env.AUTH0_CLIENT_SECRET,
  scope: 'openid profile',
  redirectUri: 'http://localhost:3000/api/callback',
  postLogoutRedirectUri: 'http://localhost:3000/',
  session: {
    // The secret used to encrypt the cookie.
    cookieSecret: process.env.COOKIE_SECRET,
    // The cookie lifetime (expiration) in seconds. Set to 8 hours by default.
    cookieLifetime: 60 * 60 * 8,
    // (Optional) The cookie domain this should run on. Leave it blank to restrict it to your domain.
    cookieDomain: 'your-domain.com',
    // (Optional) SameSite configuration for the session cookie. Defaults to 'lax', but can be changed to 'strict' or 'none'. Set it to false if you want to disable the SameSite setting.
    cookieSameSite: 'lax',
    // (Optional) Store the id_token in the session. Defaults to false.
    storeIdToken: false,
    // (Optional) Store the access_token in the session. Defaults to false.
    storeAccessToken: false,
    // (Optional) Store the refresh_token in the session. Defaults to false.
    storeRefreshToken: false
  },
  oidcClient: {
    // (Optional) Configure the timeout in milliseconds for HTTP requests to Auth0.
    httpTimeout: 2500,
    // (Optional) Configure the clock tolerance in milliseconds, if the time on your server is running behind.
    clockTolerance: 10000
  }
});

【问题讨论】:

    标签: next.js auth0


    【解决方案1】:

    不幸的是,env 变量 clientSecret: process.env.AUTH0_CLIENT_SECRET 在生产版本中以某种方式被禁用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-19
      • 2021-10-12
      • 2021-10-14
      • 2021-06-16
      • 1970-01-01
      • 2020-11-05
      • 1970-01-01
      • 2017-08-26
      相关资源
      最近更新 更多