How to solve No Access Control Allow Origin with elastic search

Posted By : Ankush Kocher | 13-Jan-2015

To use elastic search on client side we have to sent Ajax request to crossDomain request to elastic search URL.
localhost:9200 for localhost.

It give following error.

XMLHttpRequest cannot load http://localhost:9200/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
 

This error is with elasticsearch 1.4.2 . when I try to send cross domain Ajax request.

To solve this we have to enable cors in elasticsearch.yml  .

elasticsearch.yml  is in /config/elasticsearch.yml do following changes in this file.

http.cors.enabled : true

http.cors.allow-origin : "*"
http.cors.allow-methods : OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type, Content-Length
 

we can also use jsonp request method to ride over this error.To allow jsonp request to elastic search 
 uncomment

http.jsonp.enable: true
 

in elasticsearch.yml

ThankYou.

About Author

Author Image
Ankush Kocher

Ankush is a bright web app developer with expertise in Groovy and Grails development. Ankush is also an expert AngularJS developer.

Request for Proposal

Name is required

Comment is required

Sending message..
Yono Rummy YonoRummy Rummy Codes Rummy Promo Codes Rummy Yono App Yono Rummy APK Game Yono Rummy Yono Rummy Games sarkari naukri dunia TOTOSGP TOTO SGP TOTOSGP TOTO SGP TOTOSGP TOTOSGP India Games Online Platform Popular Games in India India Gaming Experience Online Games India Best Rummy Games in India India Games Collection Teen Patti Games India Rummy Games Online India India Rummy Gaming Platform Popular Rummy Platform India Online Rummy Games India India Mobile Gaming India Gaming Platform Indian Online Games India Games and Entertainment India Gaming Community India Online Gaming Platform Teen Patti Online Games India Rummy and Teen Patti Games