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) });

Explanation

The interceptor reads req.context.get(SKIP_AUTH) and forwards the request unchanged. It's cleaner than matching URLs.

Further reading

Problem with a question

Angular · Middle · question 56

Test yourself

Take the Angular · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz