# createHeadersWithRecordingId

Canonical: <https://test-proxy-recorder.dev/docs/reference/api/functions/createheaderswithrecordingid/>
Docs index: <https://test-proxy-recorder.dev/docs/> · All docs as one file: <https://test-proxy-recorder.dev/llms-full.txt>

---

> **createHeadersWithRecordingId**(`requestHeaders`, `additionalHeaders?`): `Record`\<`string`, `string`\>

Defined in: [nextjs/middleware.ts:115](https://github.com/asmyshlyaev177/test-proxy-recorder/blob/d1bacb3b39a3cf6f7f5a5391a8201868e4629861/packages/test-proxy-recorder/src/nextjs/middleware.ts#L115)

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

### requestHeaders

`Headers` \| `NextJSRequest`

Next.js headers object or NextRequest from next/server

### additionalHeaders?

`Record`\<`string`, `string`\> = `{}`

Optional additional headers to include

## Returns

`Record`\<`string`, `string`\>

Headers object with recording ID if present

## Example

```ts
// 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());
}
```
