Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ossmate opened this issue Mar 23, 2020 · 7 comments
Open

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

ossmate opened this issue Mar 23, 2020 · 7 comments

Comments

@ossmate
Copy link

ossmate commented Mar 23, 2020

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

@Miquelllabres
Copy link

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

@Miquelllabres
Copy link

I did remove the changeOrigin and it works. cheers

@ossmate
Copy link
Author

ossmate commented Mar 24, 2020

I did remove the changeOrigin and it works. cheers

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

@afrancht
Copy link

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.

@Devanshi-123
Copy link

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.

@valeriia-bohachevska
Copy link

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/" }));
};

@IROCX
Copy link

IROCX commented Nov 7, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants