title: Passport.js Google strategy is not working with the React application
body: <p>I am using passport.js google strategy for user authentication.
  I am using OAUTH2.</p>
  
  <p>When I launch my server and hit API through browser, it launches google signin page.
  But when I hit API from react front-end, it never launches the googles signin page.</p>
  
  <p>Please find below server code,</p>
  
  <pre><code>const bodyParser = require('body-parser');
  const express = require('express');
  const passport = require('passport');
  const GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
  const app = express();
  const cors = require('cors');
  
  app.use(passport.initialize());
  app.use(passport.session());
  app.use(cors());
  
  app.use((req, res, next) =&gt; {
      res.setHeader("Access-Control-Allow-Origin", "*");
      res.setHeader(
          "Access-Control-Allow-Methods",
          "GET, POST, OPTIONS, PUT, PATCH, DELETE"
      );
      res.setHeader(
          "Access-Control-Allow-Headers",
          "X-Requested-With,content-type"
      );
      res.setHeader("Access-Control-Allow-Credentials", true);
      next();
  });
  
  app.use(bodyParser.urlencoded({
      extended: true
  }));
  app.use(bodyParser.json());
  
  
  passport.use('google', new GoogleStrategy({
      clientID: "clientID", -- my client id
      clientSecret: "clientSecret", -- my clientsecret
      callbackURL: "callbackURL" -- url
  },
      function (accessToken, refreshToken, profile, done) {
          // User.findOrCreate({ googleId: profile.id }, function (err, user) {
          //  console.log(err,user);
          //   return done(err, user);
          // });
          console.log(profile);
          return done(err, user);
      }
  ));
  
  app.get('/googleauth',
      passport.authenticate('google', { scope: ['https://www.googleapis.com/auth/plus.login'] }));
  
  passport.serializeUser(function (user, done) {
      done(null, user);
  })
  
  passport.deserializeUser(function (user, done) {
      done(null, user);
  })
  
  app.listen(4000, () =&gt; {
      console.log("REST server started on port 4000");
  });
  </code></pre>
  
  <p>Axios call from react code,</p>
  
  <pre><code>  handleJGoogleLogin(e) {
      e.preventDefault();
      var current = this;
      axios.get('http://localhost:4000/googleauth')
        .then(function (response) {
          console.log(response);
        })
        .catch(function (error) {
          console.log(error);
        });
    }
  </code></pre>
  
  <p>I am stuck here, looking for some help.</p>
  
  <p>Thanks in advance</p>