WARNING: Version 5.x has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Basic Authedit
You can provide your credentials in the node(s) URL.
const { Client } = require('@elastic/elasticsearch') const client = new Client({ node: 'https://username:password@localhost:9200' })
Or you can use the full node declaration.
const { URL } = require('url') const { Client } = require('@elastic/elasticsearch') const client = new Client({ node: { url: new URL('https://username:password@localhost:9200'), id: 'node-1', ... } })