来自React Axios的Elasticsearch调用403

时间:2017-10-03 20:25:53

标签: reactjs elasticsearch axios

我运行了一个Elasticsearch节点,我可以使用chrome成功地从网址localhost:8882/rest/search/all收到Json响应。

然而,当我从这样的反应中调用它时:

var config = {
          headers: {'Access-Control-Allow-Origin': '*', 
                    'Accept': 'application/json',
                    'Content-Type': 'application/json',
                    }
        };
axios.get('http://localhost:8882/rest/search/all',config).then(function (response) {...

我收到403错误: Failed to load localhost:8882/rest/search/all; Response to preflight request doesn't pass access control check : No 'Access-Control-Allow-Origin' header is present on the requested resource

0 个答案:

没有答案