I am trying to connect my front-end React app with a local elasticsearch node. I am using ReactiveSearch to connect elasticsearch. My server is running on Digital Ocean and it's running Ubuntu 16.04. I followed their quickstart guide to get elasticsearch running on the server and have added the following lines to my elasticsearch.yml 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
My ReactJS component looks exactly like the ReactiveSearch getting started says it should look:
<ReactiveBase
app="users"
url="http://localhost:9200">
<DataSearch
componentId="SearchSensor"
dataField={["email", "username", "name"]}
title="Search"
placeholder="Search for users..."
/>
</ReactiveBase>
But, I am getting CORS errors for the preflight request headers:
When I try to visit the url: http://localhost:9200/users/active/_msearch
, I get this response:
{"error":{"root_cause":[{"type":"parse_exception","reason":"Failed to derive xcontent"}],"type":"parse_exception","reason":"Failed to derive xcontent"},"status":400}
But, if I go to the url: http://localhost:9200/users/active/1
it actually works and brings up that object:
{"_index":"users","_type":"active","_id":"1","_version":1,"found":true,"_source":{ "name": "Jon Stevens", "email": "jon@vendorpay.io" }}
What in the world is going on here?? Any help is greatly appreciated!
SCREENSHOT OF REQUEST/CONSOLE: