adambard/angular-elasticsearch-demo

XMLHttpRequest cannot load ....

Opened this issue · 3 comments

gg4u commented

Hi Adam!

thank you for your tutorial !

So I'd like to learn angular: I downloaded the db of recipes, ES, and created an index (following your tutorial).

i run the site:
http://localhost/~gg4u/angular-elasticsearch-demo-master/?q=rendang
but got errors (see below).

What does it mean? Should I enable CORS?
Is it a problem with Angular or ES? How to fix it?

http://localhost:9200/~gg4u/angular-elasticsearch-demo-master/?q=rendang
return
{"error":"IndexMissingException[[~gg4u] missing]","status":404}

http://localhost:9200/recipes/recipe/_search
works

In console, for index.html
XMLHttpRequest cannot load http://localhost:9200/recipes/recipe/_search. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. localhost/:1
ERROR: 2014-11-15T21:30:08Z
Error: Request error, retrying -- Connection Failure
at Log.error (http://localhost/~gg4u/angular-elasticsearch-demo-master/bower_components/elasticsearch/elasticsearch.angular.js:31083:60)
at checkRespForFailure (http://localhost/~gg4u/angular-elasticsearch-demo-master/bower_components/elasticsearch/elasticsearch.angular.js:31782:18)
at http://localhost/~gg4u/angular-elasticsearch-demo-master/bower_components/elasticsearch/elasticsearch.angular.js:30527:7
at wrappedErrback (http://localhost/~gg4u/angular-elasticsearch-demo-master/bower_components/angular/angular.js:11582:78)
at wrappedErrback (http://localhost/~gg4u/angular-elasticsearch-demo-master/bower_components/angular/angular.js:11582:78)
at wrappedErrback (http://localhost/~gg4u/angular-elasticsearch-demo-master/bower_components/angular/angular.js:11582:78)
at http://localhost/~gg4u/angular-elasticsearch-demo-master/bower_components/angular/angular.js:11715:76
at Scope.$eval (http://localhost/~gg4u/angular-elasticsearch-demo-master/bower_components/angular/angular.js:12702:28)
at Scope.$digest (http://localhost/~gg4u/angular-elasticsearch-demo-master/bower_components/angular/angular.js:12514:31)
at Scope.$apply (http://localhost/~gg4u/angular-elasticsearch-demo-master/bower_components/angular/angular.js:12806:24)

elasticsearch.angular.js:31397Console.write elasticsearch.angular.js:31397(anonymous function) elasticsearch.angular.js:31411bound elasticsearch.angular.js:10847EventEmitter.emit elasticsearch.angular.js:622Log.error elasticsearch.angular.js:31083checkRespForFailure elasticsearch.angular.js:31782(anonymous function) elasticsearch.angular.js:30527wrappedErrback angular.js:11582wrappedErrback angular.js:11582wrappedErrback angular.js:11582(anonymous function) angular.js:11715Scope.$eval angular.js:12702Scope.$digest angular.js:12514Scope.$apply angular.js:12806done angular.js:8379completeRequest angular.js:8593xhr.onreadystatechange angular.js:8532
XMLHttpRequest cannot load http://localhost:9200/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. localhost/:1
WARNING: 2014-11-15T21:30:08Z
Unable to revive connection: http://localhost:9200/

elasticsearch.angular.js:31397
WARNING: 2014-11-15T21:30:08Z
No living connections

elasticsearch.angular.js:31397

Looks like an issue with elasticsearch (although it could be your browser too). Try enabling CORS on elasticsearch (http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/modules-http.html)

@gg4u Were you able to resolve this issue? I'm currently experimenting a similar issues on CORS

I am playing around with this currently (1 year passed :) )
@JayKan
in elasticsearch.yml add these 2 params:
http.cors.enabled: true
http.cors.allow-origin: "*"

https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-http.html