From 8f5e7187af44cc4ff19511158367de6cf284a230 Mon Sep 17 00:00:00 2001 From: artmizu Date: Sun, 19 Jan 2025 11:52:45 +0900 Subject: [PATCH] fix: allow patching the global fetch --- src/runtime/internal/app.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/runtime/internal/app.ts b/src/runtime/internal/app.ts index 9c330a89f1..0e7d18c74b 100644 --- a/src/runtime/internal/app.ts +++ b/src/runtime/internal/app.ts @@ -85,9 +85,13 @@ function createNitroApp(): NitroApp { preemptive: true, }); + // Allow patching the global fetch + const fetchWrapper = (...args: Parameters) => + globalThis.fetch(...args); + // Create local fetch callers const localCall = createCall(toNodeListener(h3App) as any); - const _localFetch = createLocalFetch(localCall, globalThis.fetch); + const _localFetch = createLocalFetch(localCall, fetchWrapper); const localFetch: typeof fetch = (input, init) => _localFetch(input as RequestInfo, init as any).then((response) => normalizeFetchResponse(response)