Core
basicAuthHttpInterceptor
HTTP interceptor that sets an Authorization: Basic … header from credentials.
@defjs/core · Function
Signature
function basicAuthHttpInterceptor( fn: () => BasicCredential, options?: BasicAuthInterceptorOptions, ): HttpInterceptor;
It sets Authorization: Basic <encoded> on a copy of the request headers,
replacing any existing Authorization header. The default encoder is
btoa(`${username}:${password}`), so credentials must be Latin-1. Without
encode, calling basicAuthHttpInterceptor throws
Error: BasicAuthInterceptor is not supported in this environment when btoa
is not available in the runtime. Use basicAuthSSEInterceptor for SSE
operations.
Parameters
Prop
Type
fn () => BasicCredentialFactory returning username/password for each request.
options? BasicAuthInterceptorOptionsOptional custom encoder (defaults to btoa).
Returns
An HttpInterceptor that injects basic auth.