NestJS · Junior · Question 14 of 75
What is a typical way to load environment configuration in Nest?
- ✓Correct answer:
ConfigModule.forRoot()from@nestjs/config, then injectConfigServicewhere needed - 2Hard-code values in
main.ts - 3Read
.envmanually in every controller
Explanation
forRoot loads .env and can validate variables with a schema. isGlobal: true makes ConfigService available everywhere.