From cec4fb7ede7fee7b5621c096f3d5a4863b7b484e Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Sun, 20 Oct 2024 16:49:11 -0400 Subject: refactor config and add allowed_hosts --- src/web/core/core.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/web/core/core.php') diff --git a/src/web/core/core.php b/src/web/core/core.php index feaecdf..4c341c2 100644 --- a/src/web/core/core.php +++ b/src/web/core/core.php @@ -43,10 +43,16 @@ abstract class Core { $host = $_SERVER['HTTP_HOST']; - if (ENVIRONMENT == 'production') - $host = lang('domain'); + if (ENVIRONMENT == 'production') { + $default = CONFIG['domain']; + $allowed = CONFIG['allowed_hosts']; + if (!is_array($allowed)) + $allowed = [$allowed]; + if (!in_array($host, $allowed)) + $host = $default; + } - $base = lang('base_path'); + $base = CONFIG['base_path']; $url = "{$scheme}://{$host}{$base}{$path}"; if ($timestamp) { $time = Core::asset_stamp($path); -- cgit v1.2.3-freya