首页 > 解决方案 > 护照-谷歌-oauth20 不能在生产中工作?

问题描述

它在开发中运行良好,但是当我尝试在生产中使用它时,一旦我选择了我的谷歌帐户,它就会继续加载而不重定向,直到连接超时。这是我的 googleStrategy 代码:

    passport.use(
  new GoogleStrategy(
    {
      clientID: keys.googleClientID,
      clientSecret: keys.googleClientSecret,
      callbackURL: "/auth/google/callback",
      proxy: true
    },
    (accessToken, refreshToken, profile, done) => {
      User.findOne({ googleId: profile.id }).then(existingUser => {
        if (existingUser) {
          done(null, existingUser);
        } else {
          new User({ googleId: profile.id })
            .save()
            .then(user => done(null, user));
        }
      });
    }
  )
);

我也尝试在回调 URL 中使用绝对路径,但它不起作用。

标签: node.jsexpressgoogle-oauth

解决方案


推荐阅读