title: I encountered a problem while working on my project on MERN Stack
body: <p>I encountered a problem while working on my project on MERN Stack.</p>
  
  <p>My React app is running on port 3000 and express api on 5000. What I encountered is, while adding 0auth functionality using redux, I am getting error like "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource <a href="https://accounts.google.com/o/oauth2/v2/auth?response_type=code&amp;redirect_uri=http%3A%2F%2Flocalhost%3A5000%2Fapi%2Fusers%2Fauth%2Fgoogle%2Fcallback&amp;scope=profile%20email&amp;client_id=179135553003-e1nc4fhiudav4jvduad7n1dvr2hsqtj9.apps.googleusercontent.com" rel="nofollow noreferrer">here</a>. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing)."</p>
  
  <p>Now the structure of my logic is like :</p>
  
  <p>I have defined google strategy for passport. Defined routes in express route (<a href="http://localhost:5000/api/user/auth/google" rel="nofollow noreferrer">http://localhost:5000/api/user/auth/google</a>) and callback url (<a href="http://localhost:5000/api/user/auth/google/callback" rel="nofollow noreferrer">http://localhost:5000/api/user/auth/google/callback</a>). Now when I am directly accessing "<a href="http://localhost:5000/api/user/auth/google" rel="nofollow noreferrer">http://localhost:5000/api/user/auth/google</a>", I am able to complete process, but when I am calling it through reducers from react app, I am getting above mentioned error.</p>
  
  <p>My code is the following:</p>
  
  <pre><code>// Routes
  router.get(
    "/auth/google",
    passport.authenticate("google", {
      scope: ["profile", "email"]
    })
  
  );
  router.get(
    "/auth/google/callback",
    passport.authenticate("google", {
      failureRedirect: "/",
      session: false
    }),
    function(req, res) {
      var token = req.user.token;
      console.log(res);
      res.json({
        success: true,
        token: 'Bearer ' + token,
      });
    }
  );
  
  
  //Reducers Action
  
  export const googleLoginUser = () =&gt; dispatch =&gt; {
    axios
      .get('api/users/auth/google')
      .then((res) =&gt; {
        //save to local Storage
        const {
          token
        } = res.data;
        // Set token to local storage
        localStorage.setItem('jwtToken', token);
        //set token to auth header
        setAuthToken(token);
        // Decode token to get user data
        const decoded = jwt_decode(token);
        console.log(decoded);
        // set current user
        dispatch(setCurrentUser(decoded));
      })
      .catch(err =&gt; {
          console.log(err);
          dispatch({
            type: GET_ERRORS,
            payload: err.response.data
          })
        }
      )
  }       
  </code></pre>