使用fiddler对浏览器中的网站进行抓包时可能会出现跨域问题导致抓包失败。
解决方法:
1.从工具栏菜单的 Rules->Customize Rules 进入。
2.使指定URL支持CORS跨域请求。
支持 CORS 跨域,就是要为请求的返回头增加 Access-Control-Allow-Origin 属性,因此需要修改 OnBeforeResponse函数,在该函数的末尾添加 CORS 逻辑, 代码:
static function OnBeforeResponse(oSession: Session) { ... if(oSession.uriContains("要处理的url")){ oSession.oResponse["Access-Control-Allow-Origin"] = "允许的域名"; oSession.oResponse["Access-Control-Allow-Credentials"] = true; } }
3.在autoresponder 中勾选“enable rules”和“unmatched requests passthrough” 后,添加上相应的域名。
完成以上操作就可以抓包成功了。