'Interceptors provided in root being ignored for services provided in feature modules

I have a TokenInterceptor provided in my root, which will add the token to the header of each request.

@NgModule({
  declarations: [AppComponent],
  imports: [
    ...
    AuthModule, // separate auth module
    ...,
  ],
   
  bootstrap: [AppComponent],
})
export class AppModule {
}

And my AuthModule

@NgModule({
  imports: [
    StoreModule.forFeature('auth', authReducer),
    EffectsModule.forFeature([UserAuthEffects]),
    JwtModule.forRoot({
      config: {
        tokenGetter,
        authScheme: 'Bearer ',
        allowedDomains: [],
        disallowedRoutes: [/sign-in/, /account\/switchto/],
      },
    }),
  ],
  exports: [],
  providers: [
    {
      provide: HTTP_INTERCEPTORS,
      useClass: TokenResponseInterceptor,
      multi: true,
    },
  ],
})
export class AuthModule {}

Now I want to create a generic service, that I could provide in separate feature modules with different types and differen parameters.

@Injectable()
export class GenericPropertiesService<T> {
...
}

An I provide it in feature modules:

@NgModule({
  providers: [
    GenericPropertiesService,   
  ],
})
export class Feature1Module {
}

The problem is now, that every request from the GenericPropertiesService is being called without the token, I'm not sure why..



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source