Skip to content

About Headers

Headers can be overwritten if specified elsewhere.

Here's the priority from most important to least:

  1. Method headers property.
  2. Instance headers property.
  3. Instance auth property.
  4. Default headers.

This means that, for example, an Authorization header set on download will overwrite the auth property.

ts
let cobalt = new Cobalt({
    instance: 'https://cobalt.instance.example/',
    auth: { 
        scheme: 'Api-Key', 
        token: 'api-key-1'
    } 
});

await cobalt.download('https://www.youtube.com/watch?v=VUFr92i5jkA', {
    headers: { 'Authorization': 'Api-Key api-key-2' } 
});

// Final Authorization header: "Api-Key api-key-2"