> ## Documentation Index
> Fetch the complete documentation index at: https://bunnynet-cb9733c2-add-new-partner-apis.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Modify response body (Middleware)

> Use a middleware script to change the response body coming back from the origin before it is cached.

This middleware reads the HTML response from the origin and appends
`- bunny.net` to the contents of the `<title>` tag, so every page carries it.

```ts theme={null}
import * as BunnySDK from "@bunny.net/edgescript-sdk";

/**
 * When a response is not served from the cache, you can use this event handler
 * to modify the response coming from the origin. This runs before the response
 * is cached.
 *
 * Returns an HTTP response.
 * @param {Context} context - The context of the middleware.
 * @param {Request} request - The current request done to the origin.
 * @param {Response} response - The HTTP response or string.
 */
async function onOriginResponse(context: {
  request: Request;
  response: Response;
}): Promise<Response> | Response | void {
  let body = await context.response.text();
  body = body.replace("</title>", "- bunny.net</title>");

  // Remove the original Content headers so the response is returned correctly
  const headers = new Headers(context.response.headers);
  headers.delete("Content-Length");
  headers.delete("Content-Encoding");

  return new Response(body, {
    status: context.response.status, // Preserve the original status code
    headers, // Preserve the original headers
  });
}

BunnySDK.net.http.servePullZone().onOriginResponse(onOriginResponse);
```
