title: Redirect to previous page using passport.js facebook strategy in express
body: <p>This question have been posted before, <a href="https://stackoverflow.com/questions/13335881/redirecting-to-previous-page-after-authentication-in-node-js-using-passport-js">but somehow the given recommendations don't work form me</a>. Am stuck on this and not sure how to proceed. </p>
  
  <p>I can't redirect the user back after its authentication. I'm using the recommended '<strong>successReturnToOrRedirect</strong>' property, but it keeps sending it back to '/'. I have checked <strong>req.session.returnTo</strong> and <strong>req.path</strong> and both of them have  '/' as value, even though I'm calling /auth/facebook from a different page.</p>
  
  <p>Here's my code:</p>
  
  <pre><code> router.get('/auth/facebook', passport.authenticate('facebook', {scope: ['email', 'public_profile', 'user_friends']}));
  
  router.get('/auth/facebook/callback', 
  
        passport.authenticate('facebook', { successReturnToOrRedirect: '/',
                                            failureRedirect: '/' })
  
      );
  </code></pre>
  
  <p></p>
  
  <pre><code>    &lt;a href="/auth/facebook"&gt; &lt;div class="fb-button-login"&gt;
              &lt;i class="fa fa-facebook" aria-hidden="true"&gt;&lt;/i&gt;
              Continuar con &lt;strong&gt; facebook&lt;/strong&gt;
          &lt;/div&gt; &lt;/a&gt;
  </code></pre>