Function: createFetchTransport()
ts
function createFetchTransport(): CmcdTransportAdapter;Defined in: createFetchTransport.ts:43
Create a transport adapter for CmcdReportRecorder that patches globalThis.fetch to capture requests with CMCD data. The patched fetch normalizes each request to HttpRequest (lowercase headers, body read as a UTF-8 string).
The patched fetch reads each body once with Request.text() for inspection. This read is safe for the body types that CMCD reports use in practice: string, Blob, ArrayBuffer, FormData, and URLSearchParams. The underlying fetch can read those bodies again. Do not pass a ReadableStream as init.body. The patched fetch consumes the stream, and the underlying fetch receives an already-disturbed stream.