Skip to content

installNodeFetchClassParity

Nodepod API


Nodepod API / src / installNodeFetchClassParity

installNodeFetchClassParity(): void

Defined in: src/polyfills/fetch-response.ts:76

Node.js parity for the Fetch API in worker realms.

Browsers enforce “forbidden header” guards inside the Request/Response constructors: new Request(url, {headers: {cookie}}) silently drops Cookie/Host/Origin, and new Response(body, {headers}) silently drops Set-Cookie. Node (undici) has no such guards, so server frameworks that round-trip Node requests through Fetch objects (Hono, SvelteKit adapters, Fetch→Node HTTP bridges, …) lose session cookies when run in a browser worker.

This replaces the realm’s Request/Response with subclasses whose headers property is a guard-free Headers object, restoring Node semantics. Never installed in Window realms (page code keeps native behavior).

void