笔记记录之跨域报错:http://localhost/访问服务器接口
跨域报错:Access to XMLHttpRequest at ‘https://www.zykjedu.cn:9443/api.html?method=store.getstorelist’ from origin ‘http://127.0.0.1’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: The value of the ‘Access-Control-Allow-Origin’ header in the response must not be the wildcard ‘*’ when the request’s credentials mode is ‘include’. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
跨域报错原因: 浏览器(Webkit内核)的安全策略决定了file协议访问的应用无法使用XMLHttpRequest对象,请求返回200但是并没有返回数据
解决办法:找到谷歌浏览器的安装地址,
cmd 进入终端
C:\Users\pp>cd appdata
C:\Users\pp\AppData>cd local/google
C:\Users\pp\AppData\Local\Google>cd chrome
C:\Users\pp\AppData\Local\Google\Chrome>cd Application
C:\Users\pp\AppData\Local\Google\Chrome\Application>chrome.exe --disable-web-security --user-agent="Android" --user-data-dir="C:/temp-chrome-eng
C:\Users\pp\AppData\Local\Google\Chrome\Application>
然后打开 http://127.0.0.1/home/index/index.html
记录遇到的问题