Cors Error When Using Elasticsearch.js
Solution 1:
I don't know why you are getting a cross domain error to begin with. Are you opening your front end as file://.... ? Totally random guess and not sure it matters. If you are and want to run your UI through a web server, you can open a terminal, cd into that dir and run 'python -m SimpleHTTPServer 7000'. Now your UI is running on localhost:7000.
For CORS settings, see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-http.html and, if you are using Chrome, http://www.williamjohnbert.com/2013/06/allow-cors-with-localhost-in-chrome/ might help.
In your config you should at least set 'http.cors.enabled: true' and 'http.cors.allow-credentials: true'. The other defaults should be sensible. You may also want to modify the 'http.cors.max-age' setting in case old settings are cached.
Use the js console, net tab in your browser to see what headers you are getting back.
Solution 2:
Add following line to your config yml file
http.cors.enabled :truehttp.cors.allow-origin:"*"http.cors.allow-methods:OPTIONS,HEAD,GET,POST,PUT,DELETEhttp.cors.allow-headers:X-Requested-With,X-Auth-Token,Content-Type,Content-Lengthhttp.cors.allow-credentials:true
and kill elastic search java process on unix based system like is demonstrated on this topic response https://stackoverflow.com/a/41644614/11079315
Post a Comment for "Cors Error When Using Elasticsearch.js"