本文介绍了请求未通过访问控制检查:否'Access-Control-Allow-Origin'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是想从我的 http:// localhost:8080
mocky.io >
但是收到此错误:
My request looking like that:
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Access-Control-Allow-Origin', '*');
this.people = http.get('http://www.mocky.io/v2/5715f13a1100004d1187d9e1', { headers: headers })
.map(response => response.json());
解决方案
Actually you should setup the header Access-Control-Allow-Origin
in mocky.io.Just click on "Switch to Advanced mode" and you will see a "custom headers" input. Add Access-Control-Allow-Origin
and put *
as its value. Then create your mocky.io url. It should work now.
这篇关于请求未通过访问控制检查:否'Access-Control-Allow-Origin'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!