Skip to main content
zerotal

Documentation


Documentation / zerotal / client / ClientConfigShape

Interface: ClientConfigShape

Defined in: packages/client/src/config.ts:4

Extends

Properties

headers?

optional headers?: Record<string, string>

Defined in: packages/client/src/ApiClient.ts:113

Default headers sent with every request (e.g. Authorization).

Inherited from

ApiClientConfig.headers


token?

optional token?: TokenSource

Defined in: packages/client/src/ApiClient.ts:119

Bearer token attached as Authorization: Bearer <token> when no Authorization header is already present. May be a string or a (possibly async) resolver. Update at runtime with ApiClient.setToken.

Inherited from

ApiClientConfig.token


withCredentials?

optional withCredentials?: boolean

Defined in: packages/client/src/ApiClient.ts:121

Send credentials (cookies) with every request — sets credentials: 'include'.

Inherited from

ApiClientConfig.withCredentials


csrf?

optional csrf?: boolean | { cookie?: string; header?: string; }

Defined in: packages/client/src/ApiClient.ts:127

Attach the CSRF/XSRF token to mutating requests: reads the XSRF-TOKEN cookie and sends it as X-XSRF-TOKEN (the SPA/session flow). Defaults to true when withCredentials is set. Customize the cookie/header names with an object.

Inherited from

ApiClientConfig.csrf


timeout?

optional timeout?: number

Defined in: packages/client/src/ApiClient.ts:129

Default per-request timeout in ms (0/omitted = no timeout).

Inherited from

ApiClientConfig.timeout


retry?

optional retry?: number | RetryOptions

Defined in: packages/client/src/ApiClient.ts:135

Default retry policy. 2 retries idempotent requests on network errors / 5xx / 429 with exponential backoff (honoring Retry-After); pass RetryOptions to tune, or omit to disable. Per-request retry overrides this.

Inherited from

ApiClientConfig.retry


onError?

optional onError?: (error) => void | Promise<void>

Defined in: packages/client/src/ApiClient.ts:137

Called for every non-2xx response before the error is thrown.

Parameters

error

ApiClientError

Returns

void | Promise<void>

Inherited from

ApiClientConfig.onError


onForbidden?

optional onForbidden?: (error) => void | Promise<void>

Defined in: packages/client/src/ApiClient.ts:139

Called when a request receives 403 Forbidden.

Parameters

error

ApiClientError

Returns

void | Promise<void>

Inherited from

ApiClientConfig.onForbidden


onRequest?

optional onRequest?: RequestInterceptor | RequestInterceptor[]

Defined in: packages/client/src/ApiClient.ts:141

One or more request interceptors executed in order before every fetch.

Inherited from

ApiClientConfig.onRequest


onResponse?

optional onResponse?: ResponseInterceptor | ResponseInterceptor[]

Defined in: packages/client/src/ApiClient.ts:143

One or more response interceptors executed in order after every successful (2xx) response.

Inherited from

ApiClientConfig.onResponse


onUnauthorized?

optional onUnauthorized?: (error, retry) => void | Promise<unknown>

Defined in: packages/client/src/ApiClient.ts:151

Called when a request receives 401 Unauthorized. Receives the error and a retry function (optionally with header overrides) to re-execute the request once.

Parameters

error

ApiClientError

retry

(headerOverrides?) => Promise<unknown>

Returns

void | Promise<unknown>

Example

onUnauthorized: async (err, retry) => retry({ Authorization: `Bearer ${await refresh()}` }),

Inherited from

ApiClientConfig.onUnauthorized


circuitBreaker?

optional circuitBreaker?: CircuitBreaker | CircuitBreakerOptions

Defined in: packages/client/src/ApiClient.ts:156

Attach a circuit breaker (instance to share, or options to create a dedicated one).

Inherited from

ApiClientConfig.circuitBreaker


baseUrl?

optional baseUrl?: string

Defined in: packages/client/src/config.ts:5

Base URL prepended to every request path, e.g. 'https://api.example.com'.

Overrides

ApiClientConfig.baseUrl