问题
I post a form with file (enctype="multipart/form-data") to node.js (express.js framework) and just want to send this same post request like it is just to different server. what is the best approach in node.js?
回答1:
remove express.bodyParser and try pipes like these:
req.pipe(request('http://host/url/')).pipe(res)
回答2:
You could try it with Mikeal's Request for Node.js (https://github.com/mikeal/request). It would be something like:
app.post('/postproxy', function(req, res, body){
req.pipe(request.post('http://www.otherserver.com/posthandler',body)).pipe(res);
});
来源:https://stackoverflow.com/questions/9327250/how-to-resend-post-multipart-form-data-form-with-upload-file-to-different-server