This covers Angular's modern functional HTTP interceptors, which replaced the old class-based approach in recent versions. You'll use it when you need to inject auth tokens, transform requests or responses, handle errors globally, or add logging to HTTP calls. The examples show the new HttpInterceptorFn pattern with inject() for dependencies and the provideHttpClient setup with withInterceptors. Order matters when chaining multiple interceptors, and there's a handy HttpContext pattern for per-request flags like cache control. It's focused on Angular 21 conventions, so if you're still on older versions with class-based interceptors, the patterns here won't directly apply.

skills.sh installs
184
GitHub stars
7
last updated
Aug 21, 2026

Install

$ npx -y skills add oguzhan18/angular-ecosystem-skills --skill angular-interceptors --agent claude-code

Installs into .claude/skills of the current project.

Files

Angular HTTP Interceptors

Version: Angular 21 (2025) Tags: HTTP, Interceptors, Auth, Middleware

References: Interceptors Guide • API

API Changes

This section documents recent version-specific API changes.

  • NEW: Functional interceptors — Use HttpInterceptorFn instead of class-based

  • NEW: provideHttpClient with withInterceptors — Modern interceptor setup

  • NEW: HttpContext — Per-request metadata with HttpContextToken

  • DEPRECATED: Class-based HttpInterceptor — Migrate to functional

Best Practices

  • Create functional interceptor
export const authInterceptor: HttpInterceptorFn = (req, next) => {
  const authService = inject(AuthService);
  const token = authService.getToken();
  
  if (token) {
    const authReq = req.clone({
      setHeaders: { Authorization: `Bearer ${token}` }
    });
    return next(authReq);
  }
  return next(req);
};
  • Register interceptors
export const appConfig: ApplicationConfig = {
  providers: [
    provideHttpClient(
      withInterceptors([authInterceptor, logInterceptor])
    )
  ]
};

Sponsors

Details

Repository
github.com/oguzhan18/angular-ecosystem-skills
Categories
Frontend Development, Backend & APIs, Debugging
First seen
Jun 3, 2026

More from oguzhan18/angular-ecosystem-skills

All 45
1oguzhan18 avatarangular-schematicsoguzhan18/angular-ecosystem-skillsALWAYS use when working with Angular Schematics, custom generators, code generation, or building CLI tools in Angular.184skills.sh installs
2nexu-io avatarhtml-ppt-tech-sharingnexu-io/open-designConference / internal tech-talk deck — GitHub-dark, JetBrains Mono, terminal code blocks, agenda + Q&A pages. Use for engineering presentations, internal sharin183skills.sh installs
3nexu-io avatarhtml-ppt-presenter-modenexu-io/open-design演讲者模式专用 deck — tokyo-night 默认主题,5 套主题 T 键切换,每页带 150-300 字逐字稿示例(<aside class="notes">),按 S 打开 popup(CURRENT / NEXT / SCRIPT / TIMER 四张磁吸卡片)。用于技术分享、公开演讲、课程讲解,怕忘词或182skills.sh installs
4nexu-io avatarhtml-ppt-testing-safety-alertnexu-io/open-design红琥珀警示 deck — 顶/底 45° 红黑 hazard 条纹、红色删除线否定标题、L1/L2/L3 绿/琥珀/红 tier 卡片、圆点状态 alert box、policy-yaml 代码块(红左边框 + bad 关键词高亮)、红绿 checklist、Q1 事故堆叠柱状图。适合安全 / 风险 / 事故复盘 / 182skills.sh installs
5oguzhan18 avatarangular-formsoguzhan18/angular-ecosystem-skillsALWAYS use when working with Angular Forms, reactive forms, template-driven forms, form validation, or form handling in Angular applications.182skills.sh installs
6oguzhan18 avatarangular-pipesoguzhan18/angular-ecosystem-skillsALWAYS use when working with Angular Pipes, custom pipes, pure pipes, impure pipes, or async pipes in Angular applications.180skills.sh installs