title: How to modify response headers with express-http-proxy
body: <h2>Background</h2>
  
  <p>I'm using <a href="https://www.npmjs.com/package/express-http-proxy" rel="nofollow noreferrer">express-http-proxy</a> to proxy a handful of requests between my SPA (single page application) and a CouchDB instance. I'm doing this proxy on a per call basis, NOT creating a proxy server (this will be important in a moment). </p>
  
  <p>example of current use</p>
  
  <pre><code>app.use(`some/url`, proxy(dburl, {
    forwardPath: req =&gt; {return 'some/url'+require('url').parse(req.url).path;}
   }) );
  </code></pre>
  
  <p>Which means I am NOT using <code>httpProxy.createServer</code>. I want to send some snippet of text data along with my responses as a header. After looking through the <a href="https://www.npmjs.com/package/express-http-proxy" rel="nofollow noreferrer">documentation</a> I've come to the conclusion that what I want will be using <code>intercept</code>. Unfortunately I've not quite managed to grasp how to use it, and the <a href="https://stackoverflow.com/questions/12755865/rewrite-response-headers-with-node-http-proxy">only</a> <a href="https://stackoverflow.com/questions/34684139/how-to-add-headers-to-node-http-proxy-response">related</a> <a href="https://stackoverflow.com/questions/16784526/accessing-response-headers-using-node-http-proxy">questions</a> I've found so far appear to be based on <code>httpProxy.createServer</code> which appears (from my limited understanding) to work differently.</p>
  
  <p>We are using individual request proxying because we wish to proxy different requests to different micro-services, and found this to be the most concise way (that we knew of &amp; at the time) of doing that.</p>
  
  <h2>The Question</h2>
  
  <p>Given the code</p>
  
  <pre><code>const text = 'asdf';
  app.use(`some/url`, proxy(dburl, {
    forwardPath: req =&gt; {return 'some/url'+require('url').parse(req.url).path;},
    intercept: function(rsp, data, req, res, callback) {
      //SUSPECT LOCATION
    }
  }) );
  </code></pre>
  
  <p>Is there some code at <code>SUSPECT LOCATION</code> which would allow me to place <code>text</code> on the header for the final response without further affects to the (currently otherwise working) proxy?</p>
  
  <h2>Additional Notes</h2>
  
  <p>Headers and network requests in general are not very familiar to me, my apologies if the answer seems self evident.</p>
  
  <p>Bonus points for a link to a resource that helps explain either the finer points of using this library for proxying, a similar library for proxying, or the underlying technologies which would make it clear how to use this library for proxying. AKA I'd rather spend some of my own time looking further into this and not come back for further questions.</p>
  
  <p>I am not entirely confident that the place for my code will be <code>SUSPECT LOCATION</code> and I will happily listen if it needs to go somewhere else, or if we need to approach this problem in a different way.</p>