Cloudflare Docs
Visit Workers on GitHub
Set theme to dark (⇧+D)

Alter headers

Change the headers sent in a request or returned in a response.
addEventListener('fetch', event => {
async function handleRequest(request) {
const response = await fetch(request);
// Clone the response so that it's no longer immutable
const newResponse = new Response(response.body, response);
// Add a custom header with a value
newResponse.headers.append('x-workers-hello', 'Hello from Cloudflare Workers');
// Delete headers
// Adjust the value for an existing header
newResponse.headers.set('x-header-to-change', 'NewValue');
return newResponse;

You can also use the custom-headers-example template to deploy this code to your custom domain.