我使用请求在Express中为CouchDB实现以下反向代理:
app.all(/^\/db(.*)$/, function(req, res){
var db_url = "http://localhost:5984/db" + req.params[0];
req.pipe(request({
uri: db_url,
method: req.method
})).pipe(res);
});
Run Code Online (Sandbox Code Playgroud)
在进行GET请求时,它可以工作:请求从客户端到node.js再到CouchDB并成功返回.POST和PUT请求无限期挂起.日志语句一直运行到代理,但CouchDB不表示收到请求.为什么会发生这种情况,如何解决?