【发布时间】:2016-09-27 03:54:41
【问题描述】:
在某些时候,我似乎以某种方式在我的一个 Chrome 配置文件上禁用了同源策略。例如,在https://www.google.com 上,我能够在控制台中成功执行以下命令并获得完整响应:
function reqListener () {
console.log(this.responseText);
}
var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "https://www.yahoo.com");
oReq.send();
在我的其他 chrome 配置文件中,此代码给出了预期的错误:
XMLHttpRequest cannot load https://www.yahoo.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.google.com' is therefore not allowed access.
如何为我的 chrome 配置文件重新启用 SOP?
请注意,我没有使用--disable-web-security 标签(至少在不知情的情况下)。我直接打开原始可执行文件。
【问题讨论】:
标签: google-chrome google-chrome-devtools chromium same-origin-policy