私はangularjsを使ってウェブアプリを作っています。私はelasticsearch apiでリクエストしています。これはコードです:これは誤りであるangularjsを使用してelasticsearchをクロスドメインとしてリクエストする
app.controller('usersDatas', function($scope, $http){
$http.post("http://192.168.6.55:9200/userdata/_search", {headers : { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
data: "{ 'query': { 'query_string': { 'query': 'png' } } }"
// Access-Control-Allow-Origin: true
}).success(function(data){
console.log(data);
});
});
私が持っている:
XMLHttpRequest cannot load http://192.168.6.55:9200/userdata/_search. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access.
私はこれを追加しました:私のelasticsearchに
http.cors:
enable: true
allow-origin: /https?:/\/\/localhost(:[0-9]+)?/
(/etc/elasticsearch/elasticesarch.yml) config。私は問題がelasticsearchかangularjsかどうかは分かりません。 どうすればこの問題を解決できますか?おかげさまで
WindowsまたはLinuxベースのシステムまたはiosを使用していますか? – Gopinath
私はubuntu 16.04を使用しています – theCode