NG.VII · Angular 22 practice question
Why must an Angular HTTP interceptor avoid directly mutating properties on the incoming HttpRequest instance?
Check answer and explanation
Correct answer: Because HttpRequest instances are immutable, so changes must be applied by cloning the request.
Explanation
Most aspects of HttpRequest and HttpResponse are immutable, so interceptors must use the .clone() method to create a modified copy.
Common trap
HttpRequest is not a reverting proxy; its properties are designed to be immutable rather than silently rolled back. Immutability applies to HttpRequest regardless of whether the fetch or XMLHttpRequest backend is active.
Source: Angular docs: Interceptors — Modifying requests
Checked against the cited text on 2026-11-25.