Sunday, 23 April 2017

Using passport.js social authentication behind a proxy?

We have a front running on port 4040 and a back runnign on 5050.

We setup a node.js server that handles social auth the same way it's done in the passport docs:

app.get('/api/login/facebook', 
    passport.authenticate('facebook', { scope : 'email' }
));

app.get('/api/login/facebook/callback',
    passport.authenticate('facebook', {
        failureRedirect: '/api/try_again',
        successRedirect : '/api/good_job'
}));

This works when browsing directly to the local backend port, i.e: localhost:5050/api/login/facebook.

However, after setting up a proxy from webpack withhttp-proxy, and logging in with the frontend address localhost:4040/api/login/facebook it breaks and enters an infinite redirect loop.



via zehelvion

No comments:

Post a Comment