NestJS's HttpModule is shared between all of my modules, and I have some interceptors for the Axios instance of that module (same instance shared by all modules). If I configure a HttpModule, I'll lose my common interceptors because I'll get a new Axios instance.
Is there a way to add a specific header for this Axios instance just in one specific module ?
One option is to create a custom http module with some custom options type that will be passed as a argument when creating the HttpService of that module.
The creation of the http service provider will be done by useFactory
.
The, on the onModuleInit , you can check that custom. option type and add an interceptor of that specific header if needed.