向Http.get添加标头时出现Angular 2 Cors错误

时间:2016-03-13 00:33:02

标签: angularjs typescript soapui

当我打电话给 Soap ui服务时没有标题,它的工作和服务器返回json:

return this.http.get(url)
            .map(res => res.json());

但是当我添加标题时:

var headers = new Headers();
        headers.append('Content-Type', 'application/json');
        return this.http.get(url,{headers: headers})
            .map(res => res.json());

浏览器返回cors错误:

XMLHttpRequest cannot load http://desktop-0n2fu3g:8089/RechercherClients. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 404.

我已经使用标头配置了我的SOAP UI服务: enter image description here

是否有任何解决方案可以使其发挥作用?

0 个答案:

没有答案