【搬砖百宝箱】Chrome在Mac中关闭跨域限制

1,234 阅读1分钟
  1. 创建一个文件夹,例如:/Users/SaltFish/Desktop/ChromeTest

  2. 执行命令:

    open -n /Applications/Google\ Chrome.app/ --args --disable-web-security --user-data-dir=/Users/SaltFish/Desktop/ChromeTest
    
  3. 执行完会自动打开浏览器,页面如下:

  1. 验证: 可以用F12里的控制台新建个ajax请求验证。
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://www.baidu.com');
xhr.onload = function(e) {
    var xhr = e.target;
    console.log(xhr.responseText);

}
xhr.send();