title: Node.JS proxy using request module
body: <p>I have an Express.JS application that makes a proxy call for a route using request Node module. This was working well with NodeJS V0.10.28; however, upgrading to NodeJS V4.4.7 has caused this to fail -- throwing an error "Error: write after end".</p>
  
  <p>I am new to NodeJS; so I appreciate your help.</p>
  
  <pre><code>var bodyParser=require('body-Parser');
  app.use(bodyParser.json({limit: '100mb'}));
  app.use(bodyParser.urlencoded({extended: false}));
  
  ....
  ....
  
  app.use('/relay', function (req, res) {
          var request = require('request'),
              proxyUrl = 'http://abc.proxy.xyz:12345',
              apiEndPoint = "https://aaa.bbb.ccc/svc";
  
          req.pipe(request.post(apiEndPoint,{ proxy: proxyUrl, form: req.body}, function (error, response, body) {
  
              if (error) {
                  console.log(error)
              } else {
                  console.log("No error here.")
              }
  
              res.end();
  
          })).pipe(res);   
  });
  </code></pre>