* JavaScript

  ```js
  export default {
    async fetch(request) {
      const response = await fetch("https://example.com");


      // 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
      newResponse.headers.delete("x-header-to-delete");
      newResponse.headers.delete("x-header2-to-delete");


      // Adjust the value for an existing header
      newResponse.headers.set("x-header-to-change", "NewValue");


      return newResponse;
    },
  };
  ```

* TypeScript

  ```ts
  export default {
    async fetch(request): Promise<Response> {
      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
      newResponse.headers.delete("x-header-to-delete");
      newResponse.headers.delete("x-header2-to-delete");


      // Adjust the value for an existing header
      newResponse.headers.set("x-header-to-change", "NewValue");


      return newResponse;
    },
  } satisfies ExportedHandler;
  ```

* Python

  ```py
  from workers import Response, fetch


  async def on_fetch(request):
      response = await fetch("https://example.com")


      # Grab the response headers so they can be modified
      new_headers = response.headers


      # Add a custom header with a value
      new_headers["x-workers-hello"] = "Hello from Cloudflare Workers"


      # Delete headers
      if "x-header-to-delete" in new_headers:
          del new_headers["x-header-to-delete"]
      if "x-header2-to-delete" in new_headers:
          del new_headers["x-header2-to-delete"]


      # Adjust the value for an existing header
      new_headers["x-header-to-change"] = "NewValue"


      return Response(response.body, headers=new_headers)
  ```

You can also use the [`custom-headers-example` template](https://github.com/kristianfreeman/custom-headers-example) to deploy this code to your custom domain.
