Defjs
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 () => BasicCredential

Factory returning username/password for each request.

options? BasicAuthInterceptorOptions

Optional custom encoder (defaults to btoa).

Returns

An HttpInterceptor that injects basic auth.

Edit this page on GitHub
Released under the MIT License. · Copyright © 2026 MunMunMiao