how to resend post multipart/form-data form with upload file to different server with node.js (express.js)?

前端 未结 2 1186
刺人心
刺人心 2021-02-19 07:02

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. wha

相关标签:
2条回答
  • 2021-02-19 07:34

    remove express.bodyParser and try pipes like these:

    req.pipe(request('http://host/url/')).pipe(res)
    
    0 讨论(0)
  • 2021-02-19 07:38

    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);
    });
    
    0 讨论(0)
提交回复
热议问题