HTTP_INTERCEPTORS is Angular’s dependency-injection token for registering class-based HTTP interceptors as a multi-provider array. With standalone provideHttpClient, registration alone is not enough: enable those interceptors with withInterceptorsFromDi(). For new code, Angular recommends functional interceptors registered with withInterceptors([...]), which also makes their order explicit.
What HTTP_INTERCEPTORS does
HTTP_INTERCEPTORS is an Angular injection token that collects class-based HttpInterceptor instances. A multi-provider lets multiple interceptors contribute to the same token rather than replacing one another. An interceptor can inspect or modify an outgoing request and observe or transform the response as it passes through the HTTP pipeline.
As an Amazon Associate I earn from qualifying purchases.
Common patterns include adding authentication headers, retrying failures, caching, logging or measuring response times, showing loading indicators, and applying timeouts. These are options for cross-cutting HTTP behavior, not requirements for every application. See Angular’s HTTP_INTERCEPTORS API and interceptor guide.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallRegister a class-based interceptor with standalone HttpClient
In a standalone application, configure provideHttpClient with withInterceptorsFromDi(), then register each class under HTTP_INTERCEPTORS with multi: true:
#1 Best Overall
import { bootstrapApplication } from '@angular/platform-browser';
import {
HTTP_INTERCEPTORS,
provideHttpClient,
withInterceptorsFromDi,
} from '@angular/common/http';
bootstrapApplication(App, {
providers: [
provideHttpClient(withInterceptorsFromDi()),
{ provide: HTTP_INTERCEPTORS, useClass: LoggingInterceptor, multi: true },
],
});
The two configuration parts have separate jobs: the provider adds the class to the token’s multi-provider array, while withInterceptorsFromDi() tells this HttpClient configuration to read class-based interceptors from dependency injection. Without the feature, adding the token provider by itself does not enable the interceptor in this setup. Angular documents this feature in the withInterceptorsFromDi API and its HttpClient setup guide.
Use functional interceptors for new code
Angular recommends functional interceptors for new applications. Register them directly with withInterceptors:
Rank #2
provideHttpClient(
withInterceptors([loggingInterceptor, cachingInterceptor])
)
The array is an explicit ordered list: the first interceptor is first in the request chain. This is easier to inspect than relying on provider ordering across a complex hierarchy of injectors. Angular’s interceptor guide recommends the functional approach for more predictable behavior in complex setups; the withInterceptors API documents the registration method.
Class-based versus functional registration
| Approach | Registration | Enablement | Order | Angular guidance |
|---|---|---|---|---|
| Class-based | HTTP_INTERCEPTORS provider with multi: true |
In standalone provideHttpClient configuration, also use withInterceptorsFromDi() |
Depends on provider and injector configuration; can be harder to reason about in extensive hierarchies | Supported, but Angular says DI-provided interceptors may be phased out in a later release; no dated removal schedule is stated |
| Functional | withInterceptors([interceptorA, interceptorB]) |
Configured as part of provideHttpClient |
Explicit order in the array | Recommended by Angular for new code |
The possible future phase-out mentioned in the withInterceptorsFromDi API reference is not a scheduled removal. The reference does not give a date.
Rank #3
Change requests without mutating them
HTTP requests and responses are generally immutable. To adjust a request—such as adding a header—create a clone with the change rather than modifying the original request object. Be especially cautious about mutating a request’s body: bodies can contain mutable data, and a retry may run the interceptor again, making a deep mutation occur more than once. Angular covers cloning and interceptor behavior in its interceptor guide.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshoot an interceptor that does not run
- Standalone class-based setup: Confirm that the active
provideHttpClientconfiguration includeswithInterceptorsFromDi(). - Provider registration: Confirm the class is provided under
HTTP_INTERCEPTORSand that the provider usesmulti: true. - Client and injector: Check that the request uses the
HttpClientconfigured with the interceptor feature and that the provider is in the injector visible to that client. - Ordering: If several interceptors interact, inspect their order. For a functional setup, the
withInterceptors([...])array makes the intended sequence visible.
For setup details, consult Angular’s HttpClient setup guide. Angular also provides an interceptor CLI generator for creating interceptor scaffolding.
Quick Recap
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →




