Ir al contenido

createHeadersWithRecordingId

Esta página aún no está disponible en tu idioma.

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

Headers | NextJSRequest

Next.js headers object or NextRequest from next/server

Record<string, string> = {}

Optional additional headers to include

Record<string, string>

Headers object with recording ID if present

// In your API route or server component
import { 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());
}