Multiple .env for multiple countries

The Brown BoxThe Brown Box
1 min read

I don’t handle multiple countries for my own app but my app on companies do.

Having these .env files:

  • .env.production.sg

  • .env.production.uk

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      envFilePath: `.env.${process.env.RAILWAY_ENV}.${process.env.RAILWAY_COUNTRY}`,
    }),
  ],
})
export class AppModule {
  constructor() {
    console.log(`RAILWAY_ENV: ${process.env.RAILWAY_ENV}`);
    console.log(`RAILWAY_COUNTRY: ${process.env.RAILWAY_COUNTRY}`);
  }
}

Above just for non-sensitive data (which can be expose) tho…

0
Subscribe to my newsletter

Read articles from The Brown Box directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

The Brown Box
The Brown Box