从Api服务器发送文件到NodeJs到浏览器

我有一个API服务器和NodeJs服务器,当一个文件被请求时,NodeJs将请求redirect到API服务器

API服务器将文件作为原始数据发送给NodeJ,Nodejs将文件redirect到浏览器

但是当我使用Wireshark检查networking数据时,浏览器接收到的数据包不是原始数据(如果是文本文件,而不是图像,video,pdf,doc等)

router.get('/GetCaseSupportDocument', function (req, res) { var MyJsonData = { DocId:parseInt(req.query.DocId) || 0 }; request({ url: 'http://somedomain/someurl', //URL to hit method: 'POST', json: MyJsonData }, function (error, response, body) { if (error) { res.status(200).send('Failed'); } else { res.status(200).send(body); } }) }); 

任何人都可以告诉它为什么它会改变NodeJ到浏览器? 这种传输方式有没有更好的解决scheme?

更新后find解决scheme。 这工作

  router.get('/GetCaseSupportDocument', function (req, res) { var MyJsonData = { DocId:parseInt(req.query.DocId) || 0 }; request({ url: Url.CaseService + 'GetCaseSupportDocument', //URL to hit method: 'POST', json: MyJsonData }).pipe(res); }) 

有一个简单的代理使用stream,你可以尝试:

 router.get('/GetCaseSupportDocument', function (req, res) { var MyJsonData = { DocId: parseInt(req.query.DocId) || 0 }; // updated the response request({ url: 'http://somedomain/someurl', //URL to hit method: 'POST', json: MyJsonData }).pipe(res); }); 

有关代理的更多详细信息,请参阅request文档https://github.com/request/request