I created one deployed directly from the elastic cloud. I am using PGSync for synchronizing table updates with elasticsearch. Since I don't have elastic deployed on any VM I tried some settings in schema.json like this:
[
{
"setting": {
"http":{
"cors":{
"enabled": true,
"Access-Control-Allow-Credentials": true,
"Access-Control-Allow-Headers": ["Authorization", "Content-Type", "Origin", "Accept", "X-Requested-With"],
"Access-Control-Allow-Methods": ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"],
"Access-Control-Allow-Origin": "*",
"allow-headers": ["Authorization", "Content-Type", "Origin", "Accept", "X-Requested-With"],
"allow-methods": ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"],
"allow-origin": "*"
}
},
"http.cors.enabled" : true,
"http.cors.allow-origin": "*",
"http.cors.allow-methods": ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"],
"http.cors.allow-headers": ["Authorization", "Content-Type", "Origin", "Accept", "X-Requested-With"],
"http.cors.allow-credentials": true
},
"nodes": {
"table": "test",
"schema": "public"
}
// ...
}
]
I am first time using elastic search and I am getting a CORS error on the frontend side. I am directly hitting elastic API from front-end. Here is the console error I am getting while making AJAX call to elastic API:
Access to XMLHttpRequest at 'https://url/test_inde/_search?q=*' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.