getRecordingId
Ce contenu n’est pas encore disponible dans votre langue.
getRecordingId(
requestHeaders):string|null
Defined in: nextjs/middleware.ts:96
Get the recording ID from the request if present Useful for manually adding the header to fetch requests in Next.js
Parameters
Section titled “Parameters”requestHeaders
Section titled “requestHeaders”Headers | NextJSRequest
Next.js headers object or NextRequest from next/server
Returns
Section titled “Returns”string | null
The recording ID if present, null otherwise
Example
Section titled “Example”// In your API route or server componentimport { getRecordingId } from 'test-proxy-recorder/nextjs';import { headers } from 'next/headers';
export async function GET() { const recordingId = getRecordingId(headers());
const response = await fetch('http://localhost:8100/api/data', { headers: { ...(recordingId && { 'x-test-rcrd-id': recordingId }) } });
return Response.json(await response.json());}