preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin when using passport-google-oauth-2

Keywords´╝Ü javascript reactjs express redux cors

Question: 

I'm getting this error when trying to log users in with google using passport-google-oauth-2. I have a local strategy that works fine logging in and registering, but when it comes to 3rd party oauths i run into cors issues.

Access to XMLHttpRequest at 'https://accounts.google.com/o/oauth2/v2/auth?response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fusers%2Fauth%2Fgoogle%2Fcallback&scope=profile%20email&client_id=414******29387-squf9po9h437tjkknk***c4foq6734fo7.apps.googleusercontent.com' (redirected from 'http://localhost:3000/users/auth/google') from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

This is being called on the react side, and the express is using cors.

main.js

 app.use(cors({
      origin:'http://localhost:3001',
      preflightContinue: false,
      credentials: true,
      allowedHeaders: 'X-Requested-With, Content-Type, Authorization',
      methods: 'GET, POST, PATCH, PUT, POST, DELETE, OPTIONS',
      exposedHeaders: ['Content-Length', 'X-Foo', 'X-Bar'],
    }))

How its being called

users.route.js express server

router.post('/auth/google',  
    passport.authenticate('google', { scope: ['profile', 'email']}),  (req, res, next) => {
        User.forge({ email:req.body.email}).fetch().then( user => {
            // if user already exists,redirect
            if(user){
                res.send({
                    user: user,
                    success:true
                })
            } else{
                jwt.sign({ id: user.id}, process.env.JWT_SECRET, {expiresIn: 4800}, (err, token) => {
                    res.json({
                        success:true, 
                        token: token
                    })
                });
            }
        })
});

redux action(Axios is using a base instance of localhost:3000).

export const googleLogin = (userData) => dispatch => {
    Axios
      .post('/users/auth/google', userData)
      .then(res => {
        const { token } = res.data;

        console.log(token);
        // Set token to ls
        sessionStorage.setItem("jwtToken", token);
        // Set token to Auth header
        setAuthToken(token);
        // Decode token to get user data
        const decoded = jwt_decode(token);
        // Set current user
        dispatch(setCurrentUser(decoded));
      })
      .catch(err => console.log(err));
  };

Answers: