diff --git a/src/ApiKernel.php b/src/ApiKernel.php index d89d05b..f2c1049 100644 --- a/src/ApiKernel.php +++ b/src/ApiKernel.php @@ -4894,8 +4894,20 @@ SQL; private function writeDebugLog(string $name, array $payload): void { - if (strtolower((string)($this->conf['env'] ?? '')) !== 'staging') { - return; + $env = strtolower((string)($this->conf['env'] ?? '')); + if ($env !== 'staging' && (!defined('APP_ENV') || strtolower((string)APP_ENV) !== 'staging')) { + $host = ''; + if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { + $host = strtolower(trim(explode(',', (string)$_SERVER['HTTP_X_FORWARDED_HOST'])[0])); + } elseif (!empty($_SERVER['HTTP_HOST'])) { + $host = strtolower((string)$_SERVER['HTTP_HOST']); + } + if ($host !== '') { + $host = preg_replace('/:\\d+$/', '', $host); + } + if ($host !== 'staging.emailtemplate.it') { + return; + } } $dir = $this->debugDir(); if (!is_dir($dir)) {