checkAppKey method

void checkAppKey()

stop at startup when APP_KEY is missing in production. without a key, cookies and other encrypted data use an empty (predictable) key. outside production it only logs a warning.

Implementation

void checkAppKey() {
  if (config.appKey.trim().isNotEmpty) return;
  String message =
      'APP_KEY is not set. Run `dox key:generate` and put the key in .env';
  if (Env.get<String>('APP_ENV').toLowerCase() == 'production') {
    throw StateError(message);
  }
  Logger.warn(message);
}