是否可以使用Facebook ClientId和客户端封存,该端口存储在Passport.js Facebook策略中的数据库中

发布于 2025-01-29 10:54:07 字数 919 浏览 1 评论 0原文

我正在尝试使用存储在数据库中的Facebook clientId和clientsecret,

这是我的代码

passport.use(
  new FacebookStrategy(
    {
      clientID:
        process.env.AUTH_FACEBOOK_CLIENT_ID ||
        await getStringConfig('auth', `facebook_client_id`),
      clientSecret:
        process.env.AUTH_FACEBOOK_CLIENT_SECRET ||
       await getStringConfig('auth', `facebook_client_secret`),
      callbackURL: WEBSITE_URL + '/api/auth/social/facebook/callback',
      profileFields: ['languages', 'email'],

      passReqToCallback: true,
    },
    function (req, accessToken, refreshToken, profile, done) {
      socialAuthCallback(
        req as unknown as NextApiRequest,
        'facebook',
        profile,
        done
      )
    }
  )
)

getsTringConfig函数返回诺言,我知道代码不正确,但是

当我运行时, 该问题是否有任何解决方案我收到此错误的代码

错误:未启用顶级 - 怀特实验(SET EXPERMENTS.TOPLEVELAWAIT:TRUE启用启用))

I'm trying to use the Facebook clientId and clientSecret which stored in the database

this is my code

passport.use(
  new FacebookStrategy(
    {
      clientID:
        process.env.AUTH_FACEBOOK_CLIENT_ID ||
        await getStringConfig('auth', `facebook_client_id`),
      clientSecret:
        process.env.AUTH_FACEBOOK_CLIENT_SECRET ||
       await getStringConfig('auth', `facebook_client_secret`),
      callbackURL: WEBSITE_URL + '/api/auth/social/facebook/callback',
      profileFields: ['languages', 'email'],

      passReqToCallback: true,
    },
    function (req, accessToken, refreshToken, profile, done) {
      socialAuthCallback(
        req as unknown as NextApiRequest,
        'facebook',
        profile,
        done
      )
    }
  )
)

getStringConfig function returns a promise I know the code is not correct but is there any solution for this problem

when I run the code I got this error

Error: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

栀子花开つ 2025-02-05 10:54:07

您将需要设置最高水平等待在项目中使用它。在您的WebPack配置中写。

module.exports = {
  //...
  experiments: {
    topLevelAwait: true,
  },
};

You will need to set top level await to true to use it in project. In your webpack config write.

module.exports = {
  //...
  experiments: {
    topLevelAwait: true,
  },
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文