I can access the data when i just put the requet in browser 
http://localhost:9222/_cat/indices?0=b

But in my angular app this does not work returning an error saying,

XMLHttpRequest cannot load http://localhost:9222/_cat/indices?0=b. No 
'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://localhost' is therefore not allowed access.

Here is the code,

// Create the es service from the esFactory routerApp.service('es', function 
(esFactory) { return esFactory({ host: 'localhost:9222' }); }); 

routerA

pp.controller("elasticController",function($scope,es){ $scope.indexes = []; 
es.cat.indices("b",function(r,q){ var re = /open +(.+?) +1/g; matches = []; 
while (match = re.exec(q)) matches.push(match[1]); for (var i = 0; i < 
matches.length; i++) { var indObj = {id:i, index:matches[i]}; 
$scope.indexes.push(indObj); }; });

I have added the config in the elasticsearch.yml on elastic server.

http.cors.allow-origin: "/.*/"

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to