chrome增加允许跨域调用后台服务

如下报错原因是,浏览器默认是不允许跨域调用的。

Access to fetch at 'https://www.example.com/api' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
script.js:37 POST https://www.example.com/apinet::ERR_FAILED

 

 

解决方式:在chrome的快捷方式上增加如下参数

"C:\Program Files\Google\Chrome\Application\chrome.exe" --args --disable-web-security --user-data-dir=D:\temp

 

 
posted @ 2023-03-26 09:14  四代土豆2  阅读(52)  评论(0编辑  收藏  举报