FullstackReactCode icon indicating copy to clipboard operation
FullstackReactCode copied to clipboard

After loggin to app it redirect to localhost:5000/surveys

Open ossmate opened this issue 4 years ago • 7 comments

After loggin to app it redirect to localhost:5000/surveys instead of localhost:3000/surveys

authRoutes.js

  app.get(
    '/auth/google/callback',
    passport.authenticate('google'),
    (req, res) => {
      res.redirect('/surveys');
    }
  );

setupProxy.js -> instead of proxy in package.json

const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = function(app) {
  app.use(
    '/auth/google',
    createProxyMiddleware({
      target: 'http://localhost:5000',
      changeOrigin: true,
    })
  );

  app.use(
    '/api/*',
    createProxyMiddleware({
      target: 'http://localhost:5000',
      changeOrigin: true,
    })
  );
};

console identification URI http://localhost:5000 http://localhost:3000

autorizated URI http://localhost:5000/auth/google/callback http://localhost:3000/auth/google/callback

I just simply get error Cannot GET /surveys and browser URL is http://localhost:5000/surveys

ossmate avatar Mar 23 '20 21:03 ossmate

I am having the same issue, same code and also using setupProxy.js

Miquelllabres avatar Mar 23 '20 22:03 Miquelllabres

I did remove the changeOrigin and it works. cheers

Miquelllabres avatar Mar 24 '20 02:03 Miquelllabres

I did remove the changeOrigin and it works. cheers

hmm, true we will see if it's worky only for 5 min or more

ossmate avatar Mar 24 '20 19:03 ossmate

I'm having the same issue. For some reason it will not redirect back even after taking out change origin. @Miquelllabres would you mind sharing your code.

afrancht avatar May 20 '20 09:05 afrancht

I'm also having the same issue.It would be great if anyone could suggest what can be done to solve this. Removing change Origin didn't worked out for me.

Devanshi-123 avatar May 26 '20 07:05 Devanshi-123

Please, try this:

const proxy = require("http-proxy-middleware");

module.exports = function (app) {
  app.use(proxy("/auth/google", { target: "http://localhost:5000/" }));
  app.use(proxy("/api/*", { target: "http://localhost:5000/" }));
};

valeriia-bohachevska avatar Jun 08 '20 14:06 valeriia-bohachevska

In your Google auth profile change callback URL to http://localhost:3000/auth/google/callback

IROCX avatar Nov 07 '20 22:11 IROCX