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…

This post is imported from: https://thebrownbox.hashnode.dev/multiple-env-for-multiple-countries