我正在尝试使用 google 登录到我的应用程序,但它显示如下所示的错误,
XMLHttpRequest cannot load https://accounts.google.com/o/oauth2/v2/auth?response_type=code&redirect_ur…d=410427634474-u3tpasmj4r80s6v20o54s85fikhotl79.apps.googleusercontent.com. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
我已经尝试过类似下面的东西
应用程序.js
passport.use(new GoogleStrategy({
clientID : config.googleAuth.clientID,
clientSecret : config.googleAuth.clientSecret,
callbackURL : config.googleAuth.callbackURL
},
function(accessToken, refreshToken, profile, done) {
User.findOrCreate({ googleId: profile.id }, function (err, user) {
return done(err, user);
});
}
));
router.get('/pages/auth/loginWithGoogle',
passport.authenticate('google', { scope: ['https://www.googleapis.com/auth/plus.login'] }));
router.get('/auth/google/callback',
passport.authenticate('google', {
successRedirect : '/invite-friends',
failureRedirect : '/pages/auth/login'
}));