'NestJS HTTP Module needs to be imported in every feature module

In nestjs the http module needs to be imported into every feature module. Is there any way to import the http module only once throughout the full application?

Although in all the feature modules the http configurations are the same, why do we need to import and configure in each one.

Thanks.



Solution 1:[1]

You could make a global module that imports it and exports it like so:

@Global()
@Module({
  imports: [HttpModule.register(httpModuleOptions)],
  exports: [HttpModule],
})
export class GlobalHttpModule {}

Now import it in the AppModule and you can use HttpService anywhere

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Jay McDoniel