请求的资源上不存在“Access-Control-Allow-Origin”标头

时间:2017-09-18 10:01:25

标签: javascript angularjs json

 $http({
      method: 'POST',
      url: 'http://myurl',
      headers: { 'Content-Type': 'application/json', 'Accept': 'application/json'},
     data:  JSON.stringify(data)  
  }).then(function (response) {
        $scope.myData = response.data.message;

只有当我在chrome中启用CORS Filter插件时,这才有用。搜索了很多解决方案。他们都没有正常工作。请帮忙。

2 个答案:

答案 0 :(得分:1)

您需要在REST服务中添加代码以允许CORS请求。此链接非常有用:https://spring.io/understanding/CORS

答案 1 :(得分:0)

解决....!我将客户端托管在运行Web服务的同一域上。现在客户端和服务器位于同一个域中。

相关问题