Hi, 

The fact that you are able to open the 'offending' URL directly in your 
browser is not surprising.  There is no resource sharing since there is a 
single origin (the URL you opened).

Angular's access to the resource is blocked because in that case you have 2 
origins

   1. The URL of the angular app which you are running
   2. The elastic search URL from which you are fetching data

My guess is that your CORS configuration is not set up correctly (which you 
have probably figured this out by now...)

Regards
Justin



On Thursday, 19 February 2015 07:59:38 UTC+2, Sajeetharan Sinnathurai wrote:
>
> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to