title: React express paspport and google authentication redirect after login
body: <p>I am trying to use google authentication in my react, express App. I set up two callbacks redirect URI on my google auth20 client ID as shown in the attachment. I configured react proxy to redirect to the server whenever a request is made to <code>/auth/google</code> or <code>/api/*</code> in setupProxy.js because I use creat react app v2. The app redirect fine from the client-side and google authenticate the login user but google keep redirecting to <code>http://localhost:5000/auth/google/callback</code> after login in the user. I want to redirect to <code>http://localhost:3000/auth/google/callback</code> i.e. my client uri after the user is successfully login. for example <code>localhost:3000/surveys</code> instead of <code>localhost:5000/surveys</code></p>
  
  <p><strong>My setupProxy.js file content</strong></p>
  
  <pre><code> const { createProxyMiddleware } = require('http-proxy-middleware')
      module.exports = function (app) {
        app.use(
          ['/auth/google', '/api/*'],
          createProxyMiddleware({
            target: 'http://localhost:5000',
            changeOrigin: true
          })
        )
      }
  </code></pre>
  
  <p><strong>My Passport and express route handler</strong></p>
  
  <pre><code>const passport = require('passport')
  module.exports = app =&gt; {
        app.get(
          '/auth/google',
          passport.authenticate('google', {
            scope: ['profile', 'email']
          })
        )
        app.get(
          '/auth/google/callback',
          passport.authenticate('google'),
          (req, res) =&gt; {
            res.redirect('/surveys')
          }
        )
  
        app.get('/api/logout', (req, res) =&gt; {
          req.logout()
          res.redirect('/')
        })
  
        app.get('/api/current_user', (req, res) =&gt; {
          res.send(req.user)
        })
      }
  </code></pre>
  
  <p><strong>My google auth20 Client ID Settings</strong>
  <a href="https://i.stack.imgur.com/gYm4H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gYm4H.png" alt="enter image description here"></a></p>
  
  <p>Authorized redirect URIs
  <a href="http://localhost:3000/auth/google/callback" rel="nofollow noreferrer">http://localhost:3000/auth/google/callback</a>
  <a href="http://localhost:5000/auth/google/callback" rel="nofollow noreferrer">http://localhost:5000/auth/google/callback</a></p>
  
  <p>As Attached.</p>