搭建的Webservice接口,用另一个服务器访问时候报这个错误:
xxx has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://xxx' is therefore not allowed access.
解决办法:
打开IIS,找到出错的网站,进入“HTTP响应标头”
![](https://img.haomeiwen.com/i4623447/6306522738c87ff9.png)
添加一个标头
![](https://img.haomeiwen.com/i4623447/213a0bdefcc5ccef.png)
标头为Access-Contro-Allow-Origin:*
![](https://img.haomeiwen.com/i4623447/00bf109a03447cd9.png)
保存后该网站就可以访问了。
网友评论