This commit is contained in:
2026-02-02 23:44:38 +01:00
parent 153f0b225e
commit d5ecbed2db
3 changed files with 31 additions and 1 deletions

View File

@@ -10,6 +10,22 @@ $envHint = getenv('APP_ENV_FILE') ?: (getenv('APP_ENV') ?: null);
if ($envHint && !preg_match('/^[A-Za-z0-9_\-]+$/', $envHint)) {
$envHint = null;
}
if ($envHint === null) {
$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') {
$envHint = 'staging';
} elseif (preg_match('/(^|\\.)emailtemplate\\.it$/', $host)) {
$envHint = 'prod';
}
}
}
if ($envHint === null) {
if (is_dir(__DIR__ . '/staging')) {
$envHint = 'staging';