Node.js https.request not returning data as expected <p>I'm trying to proxy API requests to a sever using node's https.request() function. When I run the same request to the same endpoints with the same headers through Postman I get the data back as expected. When I run the request though the node proxy I get http 500 error codes back. Is there anything obviously wrong with the way I'm sending the requests:</p> <pre><code>#!/usr/bin/env node process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; var https = require('https'), connect = require('connect'), staticDir = 'target/ui'; var app = connect(); app.use(connect.logger('dev')) .use(connect.bodyParser()) .use(function(req, res, next){ if( /^\/api\//.test(req.url) ){ var options = { hostname: 'host.name', port: 9090, path: req.url, method: req.method, headers: { authorization: 'Basic XYZ123', 'content-type': 'application/json', accept: 'application/json, text/javascript, */*; q=0.01', } }; var proxyRequest = https.request(options).on('response', function(res){ var data = ""; res.on('data', function(chunk){ data += chunk; }) res.on('end', function(){ sendData(data); }); res.on('error', function(e){ console.log('ERROR: ', e); sendError(e, code); }) }) proxyRequest.end(); function sendData(data){ console.log('SENDING RESPONSE DATA', data) res.write(data); res.end(); } function sendError(msg, code){ res.end(msg, code) } } else { next(); } }) .use(connect.static(staticDir));; app.listen(9090); </code></pre>