I have created HTTP_INTERCEPTOR, I need it to work on some specific routes and some others not.
At the begining it was in the main app module file, then I removed it from there and add it in some modules,but it still work on all routes , then i added it in component.ts but not worked at all.
{
provide: HTTP_INTERCEPTORS,
useClass: AuthExpiredInterceptor,
multi: true,
deps: [Injector]
},
It's not possible to only specify an interceptor for certain routes and/or modules.
However, you can add a http header value that skips applying the interceptor for that request. For Example:
then in my Error handler Interceptor if the header is applied, do not catch the error and handle it, instead, let it bubble up to my services and components.
then anytime you have a HTTP request you want to be ignored add the
InterceptorSkipHeader
to the request