title: Node, express API proxy requests to external API with basic auth header
body: <p>I have built a API using node.js and express.
  But i need to be able to proxy some requests on a specific route to a external server and show the response from the external server to the clint doing the request.</p>
  
  <p>But i also need to forward the basic auth that the client is send along with the request.</p>
  
  <p>I have tried using the request module like:</p>
  
  <pre><code>app.get('/c/users/', function(req,res) {
    //modify the url in any way you want
    var newurl = 'https://www.external.com' 
    request(newurl).pipe(res),
  
  })
  </code></pre>
  
  <p>But it seems to not send the basic auth header because i get "403 Forbidden" back form the external server(www.external.com)</p>
  
  <p>The request im making is looking like:</p>
  
  <pre><code>GET http://example.se:4000/c/users/ HTTP/1.1
  Accept-Encoding: gzip,deflate
  X-version: 1
  Authorization: Basic bmR4ZHpzNWZweWFpdjdxfG1vcmV1c2*******=
  Accept: application/json
  Host: example.se:4000
  Connection: Keep-Alive
  User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
  </code></pre>
  
  <p>And it works if i do the exact same request but against www.external.com directly so there is some issue when doing the proxy in node.</p>