registerProxyAxios
このコンテンツはまだ日本語訳がありません。
registerProxyAxios<
Config>(instance):void
Defined in: nextjs/registerProxyAxios.ts:102
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 (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:
import { registerProxyAxios } from 'test-proxy-recorder/nextjs';registerProxyAxios(axiosForServer);registerProxyAxios(axiosWithAuth);- No-op in production unless
TEST_PROXY_RECORDER_ENABLEDis set (the interceptor is not even attached). - No-op in the browser — the interceptor short-circuits when
windowexists, 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
Section titled “Type Parameters”Config
Section titled “Config”Config extends ProxyAxiosRequestConfig = ProxyAxiosRequestConfig
Parameters
Section titled “Parameters”instance
Section titled “instance”ProxyAxiosInstance<Config>
the axios instance to tag server-side requests on
Returns
Section titled “Returns”void