I am using angular 5 in my project and I have already setup my elasticsearch and kibana in gcp. Everything works fine until I tried to connect it to my project. I know I have to send my credentials, but it did not work and I tried also to add some CORS in the elasticsearch.yml, but no progress at all. For my database is firebase and use it service to create my elastic search instance. I want to connect it to my project can anyone help me with this? thank you
Here's my code :
var client = new elasticsearch.Client({
host: 'http://user:pass@35.225.247.57//elasticsearch',
log: 'trace',
});
client.ping({
// ping usually has a 3000ms timeout
}, function (error) {
if (error) {
console.trace(error);
} else {
console.log('All is well');
}
});
This is the response of the server
Failed to load http://35.225.247.57//elasticsearch/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 401.
I added some CORS to elasticsearch.yml
http.cors.allow-origin: "*"
http.cors.allow-credentials: true
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, Authorization"