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)