我试图从开发环境(本地主机:4200)调用REST API的使用提示以下错误:角2(4.0.0版本)Angular2,REST服务POST调用错误:“跨来源请求阻止”
消息: “跨源请求被阻止:同源策略不允许在https://localhost:8000/auth处读取远程资源(原因:缺少CORS头'Access-Control-Allow-Origin')。”
我在这里提供一个参考代码示例:
var headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
return this.http.post(this.loginUrl, 'POST_Parameters', {
headers: headers
}).map(res => {
console.log(res);
});
可有人请帮我找出这个问题的解决方案?
的可能的复制[如何创建跨域请求(角2)?(http://stackoverflow.com/questions/34790051/how-to-create-cross-domain-request-angular-2) – Alex