Skip to content

Commit

Permalink
Strip MF-Custom-Service header from request param, closes #475
Browse files Browse the repository at this point in the history
Previously, the `MF-Custom-Service` header was including on the
`request` parameter passed to custom service functions. This usually
wasn't a problem, but if the request ever made it back to the
loopback server (e.g. via `caches.default.put(request, ...)`), it
would be forwarded back to the custom service instead of the
appropriate plugin router.
  • Loading branch information
mrbbot committed Nov 1, 2023
1 parent 694faf6 commit 6bb9a91
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/miniflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions packages/miniflare/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down

0 comments on commit 6bb9a91

Please sign in to comment.