diff --git a/packages/miniflare/src/index.ts b/packages/miniflare/src/index.ts index 3d3125592100..f429e1f80e5a 100644 --- a/packages/miniflare/src/index.ts +++ b/packages/miniflare/src/index.ts @@ -421,6 +421,7 @@ export class Miniflare { try { const customService = request.headers.get(HEADER_CUSTOM_SERVICE); if (customService !== null) { + request.headers.delete(HEADER_CUSTOM_SERVICE); response = await this.#handleLoopbackCustomService( request, customService diff --git a/packages/miniflare/test/index.spec.ts b/packages/miniflare/test/index.spec.ts index 46224206fe49..f238bb32aa6e 100644 --- a/packages/miniflare/test/index.spec.ts +++ b/packages/miniflare/test/index.spec.ts @@ -60,6 +60,9 @@ test("Miniflare: web socket kitchen sink", async (t) => { CUSTOM(request) { // Testing dispatchFetch custom cf injection t.deepEqual(request.cf, { country: "MF" }); + // Testing `MF-Custom-Service` header removed: + // https://github.com/cloudflare/miniflare/issues/475 + t.is(request.headers.get("MF-Custom-Service"), null); // Testing WebSocket-upgrading fetch return fetch(`http://localhost:${port}`, request); },