title: How to proxy to root path with node http-proxy
body: <p>I am trying to setup a proxy with an express app to a root path from a specific path in my application:</p>
  
  <pre><code>http://my-domain.com/some/route --&gt; http://another-domain:8000/
  </code></pre>
  
  <p>I have tried multiple things per the http-proxy docs but I keep hitting a wall with the paths/routing. I am trying to do this within a logged in express app so that I can utilize my authentication behind the app i'm trying to proxy too. I keep getting an error with the proxy'd app saying the path '/some/route' is not defined...etc. </p>
  
  <pre><code>var httpProxy = require('http-proxy');
  var proxy = httpProxy.createProxyServer({});
  
  proxy.proxyRequest(req, res, {
      host:'localhost',
      port:8000
  });
  </code></pre>
  
  <p>I've also tried:</p>
  
  <pre><code>var url = 'http://localhost:8000/';
  var httpProxy = require('http-proxy'),
      proxy = httpProxy.createProxyServer({});
  
  proxy.web(req,res, { target: url }, function(e) {
      console.log('proxy.web callback');
      console.log(e);
  });
  </code></pre>
  
  <p>The function calls but I end up with an express 404 error...</p>
  
  <p>I would also like to pass in some variables if that is possible so for example:</p>
  
  <pre><code>http://my-domain.com/some/route?var1=something&amp;var2=something --&gt; http://another-domain:8000/?var1=something&amp;var2=something
  </code></pre>
  
  <p>But could not figure out if that was possible, I tried setting it on the request since that was being sent into the proxyRequest, but was unable to find them in the second application.</p>