【发布时间】:2016-12-09 22:36:12
【问题描述】:
我有一个 Express.JS 应用程序,它使用请求节点模块对路由进行代理调用。这在 NodeJS V0.10.28 中运行良好;但是,升级到 NodeJS V4.4.7 导致此操作失败 - 抛出错误“错误:结束后写入”。
我是 NodeJS 的新手;非常感谢您的帮助。
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);
});
【问题讨论】:
标签: node.js express proxy request