天天看點

chrome設定--disable-web-security解決跨域

最近在做項目遇到直接請求第三方接口的。沒有背景對接人員,網上查了下有解決在chrome浏覽器中跨域的方法:

一、mac版本

  1. 打開終端
  2. 退出chrome浏覽器
  3. 輸入下面的指令( 需要替換路徑中的yourname )
sudo  open -a "/Applications/Google Chrome.app" --args --disable-web-security  --user-data-dir=/Users/yourname/chromeDevUserData/
           

執行上面後會自動打開chrome浏覽器。會提示會降低浏覽器安全。說明已經設定成功了,就可以請求跨域的接口連調了。

每次退出浏覽器後,啟動之前需要在執行上面的步驟。

二、windows版本

由于我使用的是mac在做開發,關于windows版本的設定方法,點選下面連結檢視。

windows版本請檢視大佬的總結:https://blog.csdn.net/dearwind153/article/details/52235749

三、微信開發者工具前端臨時解除跨域

微信開發者工具:open -n /Applications/wechatwebdevtools.app --args --disable-web-security --user-data-dir=/Users/xxxxxxx/MywechattoolUserData

xxxxxxx是你電腦的名字

繼續閱讀