# registerProxyAxios

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

---

> **registerProxyAxios**\<`Config`\>(`instance`): `void`

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

Attach a request interceptor to an axios instance so every **server-side**
request it makes carries the current session's recording id (`x-test-rcrd-id`),
letting the proxy tell concurrent replay sessions apart.

This is the axios counterpart to [registerProxyFetch](/docs/reference/api/functions/registerproxyfetch/) (which patches the
global `fetch`). Use it for the axios instance(s) your SSR / Server Components
make API calls through — it removes the need to hand-roll an interceptor plus a
`React.cache()`-memoized `next/headers` reader:

```ts
import { registerProxyAxios } from 'test-proxy-recorder/nextjs';
registerProxyAxios(axiosForServer);
registerProxyAxios(axiosWithAuth);
```

- No-op in production unless `TEST_PROXY_RECORDER_ENABLED` is set (the
  interceptor is not even attached).
- No-op in the browser — the interceptor short-circuits when `window` exists,
  and the id is only readable inside a server request scope anyway.
- Idempotent per instance: registering the same instance twice attaches one
  interceptor.
- Never overwrites a recording id a caller set explicitly.

## Type Parameters

### Config

`Config` *extends* [`ProxyAxiosRequestConfig`](/docs/reference/api/interfaces/proxyaxiosrequestconfig/) = [`ProxyAxiosRequestConfig`](/docs/reference/api/interfaces/proxyaxiosrequestconfig/)

## Parameters

### instance

[`ProxyAxiosInstance`](/docs/reference/api/interfaces/proxyaxiosinstance/)\<`Config`\>

the axios instance to tag server-side requests on

## Returns

`void`
