title: infinite OAuth Redirect Loop with node.js
body: <p>I'm trying to OAuth users of my single-page webapp but I'm ending with infinite redirects there.</p>
  
  <p>I registered application in express to behave like when url is hit, then redirect user to OAuth server:</p>
  
  <pre><code>expressApp.use("/", (req, res) =&gt; {
      var redirectUri = "http://myApp.com";
      var clientId = "someClientID";
      var redir = "https://someOAuth.com/oauth/authorize?response_type=code&amp;client_id=" + clientId + "&amp;redirect_uri=" + redirectUri;
      res.status(301).redirect(redir);
  });
  </code></pre>
  
  <p>But as you all expect, when OAuth server redirects user back into application, server is taking him back to OAuth server and again and again.</p>
  
  <p>Then I tried to set <code>redirecUri</code> variable to <code>"http://myApp.com/login/callback"</code> and register another path like following: </p>
  
  <pre><code>expressApp.use("/login/callback", (req, res) =&gt; {
      var redir = "http://myApp.com";
      res.status(301).redirect(redir);
  });
  </code></pre>
  
  <p>Did not help as well.</p>
  
  <p>Could you anybody help me there explaining how to handle redirect back from OAuth to my webapp correctly, please?</p>