CORS request did not succeed

At first, I tried to access Elasticsearch via a React Application. I was successful at first. But when I try the same app from another machine, Application doesn't show any data.

I am getting this following error at the console,

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://x.x.x.x:9200/_cat/indices?format=json. (Reason: CORS request did not succeed).

Following are the details of relevant configurations,


http.cors.enabled: true
http.cors.allow-origin: '*'
http.cors.allow-methods: OPTIONS, HEAD, GET, POST
http.cors.allow-headers: X-Requested-With,X-Auth-Token,Content-Type,Content-Length, Authorization
http.cors.allow-credentials: true

Following is the curl output,

curl -k -i -X OPTIONS -H "User-Agent: Mozilla" -H "Origin:" -u elastic https://x.x.x.x:9200/_data
Enter host password for user 'elastic':
HTTP/1.1 200 OK
content-type: text/plain; charset=UTF-8
content-length: 0
access-control-allow-origin: *
access-control-allow-credentials: true

Can't find where is the problem and where to start the troubleshooting.


Which browser are you on? Most (if not all) browsers have a development console where you can see the traffic live. E.g. for Chrome:

So I propose to your REACT application, open the network tab of the dev tools and start whatever you have to start to make the CORS request. Then you can check both request and response and compare it against the working Curl output.

Best regards

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.