javascript - 使用 http-proxy-middleware 从请求中删除标头
问题描述
我正在尝试使用 http-proxy-middleware 从特定请求中删除响应标头。我正在使用onProxyRes
类似的方法:
onProxyRes: (proxyRes, req, res) => {
if(req.path.endsWith('api/endpoint') {
delete proxyRes.headers['set-cookie'];
// this just to test
res.setHeader('X-proxy-header-changed', 'true');
}
}
这似乎正常工作,但在某些情况下,当调用未授权并且网关发回我的 CSP 阻止的重定向时,这不起作用并且无论如何设置了 cookie。我有一种感觉,我对这应该如何工作的理解是有缺陷的。该调用不会返回onProxyRes
回调吗?如果是这样,有没有更好的方法来做到这一点?谢谢。
解决方案
推荐阅读
- matlab - 如何从 SciPad 设置 Scilab 块中的参数?
- react-native - 使用 Redux 更改 React Native 中的初始状态
- vue.js - Vue js 更新 DOM 后加载 xmlns 模式
- javascript - 如何使用 dom 在下载中包含 row().child 行:'Bfrtip' 使用 Datatables
- javascript - 将路径数组转换为数据结构
- python - 获取日期小部件以显示美国用户的美国日期
- tensorflow - 如何为 tensorflow 创建我们自己的数据集?
- c# - 我的问题是我的玩家在跳跃时没有附着在屋顶上
- loops - 具有多个条件和循环的 groovy XPath
- opencv - OpenCV中的“增量”人脸训练