Angular · Middle · Question 56 of 75
How can a single request skip a functional interceptor (e.g. the auth header)?
export const SKIP_AUTH = new HttpContextToken(() => false);
this.http.get(url, { context: new HttpContext().set(SKIP_AUTH, true) });- ✓Correct answer: Pass an
HttpContexttoken and check it in the interceptor - 2Interceptors can't be skipped
- 3Use a different
HttpClientinstance for each request
Explanation
The interceptor reads req.context.get(SKIP_AUTH) and forwards the request unchanged. It's cleaner than matching URLs.