title: node.js: route request to different port on same host
body: <p>I have a host computer which serves a number of webapplications (not node.js based). It does this using different ports. This means that for example the following applications are live:</p>
  
  <ul>
  <li>app1: <a href="http://hostname:3000" rel="noreferrer">http://hostname:3000</a></li>
  <li>app2: <a href="http://hostname:3001" rel="noreferrer">http://hostname:3001</a></li>
  <li>app3: <a href="http://hostname:3003" rel="noreferrer">http://hostname:3003</a></li>
  </ul>
  
  <p>Next to that I have a node.js based webapp (running on port 80) which I want to use as a sort of router. When someone navigates to <a href="http://localhost/app/app1" rel="noreferrer">http://localhost/app/app1</a>. I want it to navigate to <a href="http://hostname:3000" rel="noreferrer">http://hostname:3000</a>. This is relatively straightforward using a simple redirect. However, I would want to preserve the url <a href="http://localhost/app/app1" rel="noreferrer">http://localhost/app/app1</a>. Can someone point me to a way to make this work using node.js/express?</p>
  
  <p>My routing logic looks somewhat like this (pseudo-code).</p>
  
  <pre><code>app.route('/app/:appName')
     .get(appEngine.gotoApp);
  
  appEngine.gotoApp = function(req, res) {
      redirectToApp logic 
      }
  </code></pre>