diff --git a/src/modules/auth/auth.service.ts b/src/modules/auth/auth.service.ts index 4b4d79f8..9146fe36 100644 --- a/src/modules/auth/auth.service.ts +++ b/src/modules/auth/auth.service.ts @@ -26,9 +26,11 @@ export class AuthService implements OnModuleInit { let isNewKey = false; if (count === 0) { - // Use predictable key in development, random key in production - displayKey = - process.env.NODE_ENV === 'production' ? `owa_k1_${randomBytes(32).toString('hex')}` : 'dev-admin-key'; + // Use env var if set, otherwise auto-generate predictable key in development, random key in production + displayKey = process.env.API_MASTER_KEY + || (process.env.NODE_ENV === 'production' + ? `owa_k1_${randomBytes(32).toString('hex')}` + : 'dev-admin-key'); await this.seedApiKey(displayKey, 'Default Admin Key', ApiKeyRole.ADMIN); isNewKey = true;