Hey everyone 👋
I am trying to inject an env variable loaded from the ConfigModule inside another "import" of another module - but I can make it work, where is the issue here ?
app.module.ts
@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
LogsModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
logs.module.ts
@Module({
imports: [
MongooseModule.forRoot(process.env.MONGO_URL_LOGS)
],
exports: [
LogsService
],
providers: [
LogsService
]
})
export class LogsModule {}
It says it can't connect to database, but when I hardcode the URL it's working. So I suspose that at this point, the env variable is not loaded yet
(Yes, there is a .env file, containing the variable, at the root level of the project)
Thank you in advance for your help 🙏