Description
🐛 Bug report
When setting the headers
config is set by during Client
instantiation, those custom headers will erase any default header values that the library intends to keep set, rather than merging the defaults in with the custom ones.
To reproduce
Create a client with custom headers:
const client = new Client({
headers: { 'x-custom-header': 'foobar' }.
// other required options
})
When sending a request, we would expect to see the custom header as well as any default headers provided by the client, like user-agent
:
{
'user-agent': 'elasticsearch-js/...',
'x-custom-header': 'foobar',
}
But instead you will see only the custom headers:
{
'x-custom-header': 'foobar',
}
Expected behavior
Default headers should be merged with custom headers rather than be overwritten by them.
Node.js version
any
@elastic/elasticsearch version
8.x or newer
Operating system
any