Reputation: 115
const client = new elasticsearch.Client({
host: [
{
host: '35.192.45.130//elasticsearch',
auth: 'user:password',
protocol: 'http',
port: 80
}
]
});
//
await client.ping({
// ping usually has a 3000ms timeout
requestTimeout: 1000
}, function (error) {
if (error) {
console.trace('elasticsearch cluster is down!');
} else {
console.log('All is well');
}
});
I can't authorize to elasticsearch with ionic. But with Postman i already can login and do some actions.
Error is
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access. The response had HTTP status code 401.
Upvotes: 1
Views: 110
Reputation: 772
Solution was to enable CORS in a browser using this plugin in chrome browser.
More about CORS here
Upvotes: 1