我将带有文件(enctype ="multipart/form-data")的表单发布到node.js(express.js框架),并且只想发送这个相同的发布请求,就像它只是发送到不同的服务器一样.node.js中最好的方法是什么?
删除express.bodyParser并尝试这样的管道:
req.pipe(request('http://host/url/')).pipe(res)
Run Code Online (Sandbox Code Playgroud)
您可以尝试使用Mikeal的Node.js请求(https://github.com/mikeal/request).它会是这样的:
app.post('/postproxy', function(req, res, body){
req.pipe(request.post('http://www.otherserver.com/posthandler',body)).pipe(res);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4967 次 |
| 最近记录: |