setHeader(name, value) Last updated: 17. Oct 2026
API only function
Sets a header value in the response.
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | The name of the header to set. |
| value | string | The value to set for the header. |
Returns
Nothing. Throws if the name is empty.
Headers set here are applied last, so they override headers Docly sets itself, such as Cache-Control. Setting the same name twice keeps the last value.
Example
Code example (JS)
JS is normal JavaScript either running in the browser or on the Docly™ server.// Set a custom header in the response
docly.setHeader("X-Custom-Header", "CustomValue");