title: Difference between req.url and req.originalUrl in Express.js version 4
body: <p>I am trying to implement login feature in Express.js version 4 app. I need to determine whether an user is logged in before he can do certain actions. So I have a middleware called as <code>isLoggedIn</code> which solely checks if user object is in session, if not, the user is redirected to login page. After the user successfully logs in, he must be redirected to the original URL.</p>
  <pre class="lang-js prettyprint-override"><code>app.get('/someaction', isLoggedIn, 'actual function to be executed'); 
  </code></pre>
  <p>Now inside <code>isLoggedIn</code> method, I see that <code>req.url</code> and <code>req.originalUrl</code> contains the requested action. However if the user is not logged in, when redirected to <code>/login</code> page, both <code>req.url</code> and <code>req.originalUrl</code> has <code>/login</code> as the contents. From what I read <a href="http://expressjs.com/api.html#req.originalUrl" rel="noreferrer">here</a>, I can override req.url for internal routing purposes. But in my case both <code>req.url</code> and <code>req.originalUrl</code> gets overridden by <code>/login</code> action.</p>
  <p>What am I doing wrong?</p>