相关疑难解决方法(0)

在管道之前编辑响应标头

对于Express中的某些请求,我有一个小代理.使用请求库,我有相当简洁的代码:

app.use('/api', function(req, res) {
    var url = rewriteUrl(req.url);

    var newReq = request(url, function(error) {
        if (error) {
            logError(error);
        }
    });

    req.pipe(newReq).pipe(res);
});
Run Code Online (Sandbox Code Playgroud)

我的问题是来自API服务器的响应包含一堆我想要删除的不需要的标头.如何在将其汇总到newReq之前从响应中删除标题res

node.js express

33
推荐指数
3
解决办法
1万
查看次数

标签 统计

express ×1

node.js ×1