createHeadersWithRecordingId
Ce contenu n’est pas encore disponible dans votre langue.
createHeadersWithRecordingId(
requestHeaders,additionalHeaders?):Record<string,string>
Defined in: nextjs/middleware.ts:130
Create headers object with recording ID for fetch requests Use this helper when making fetch requests in Next.js to forward the recording ID
Parameters
Section titled “Parameters”requestHeaders
Section titled “requestHeaders”Headers | NextJSRequest
Next.js headers object or NextRequest from next/server
additionalHeaders?
Section titled “additionalHeaders?”Record<string, string> = {}
Optional additional headers to include
Returns
Section titled “Returns”Record<string, string>
Headers object with recording ID if present
Example
Section titled “Example”// In your API route or server componentimport { createHeadersWithRecordingId } from 'test-proxy-recorder/nextjs';import { headers } from 'next/headers';
export async function GET() { const response = await fetch('http://localhost:8100/api/data', { headers: createHeadersWithRecordingId(headers(), { 'Content-Type': 'application/json', }) });
return Response.json(await response.json());}