From c4ce94414fefbc1f9cca723f720f4d56c1558cca Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Mon, 22 Nov 2021 12:21:40 +1300 Subject: [PATCH] ENH Call baseURL() instead of just alternate_base_url --- src/Control/Director.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Control/Director.php b/src/Control/Director.php index 2afa4518e82..08399fc9de9 100644 --- a/src/Control/Director.php +++ b/src/Control/Director.php @@ -556,7 +556,7 @@ public static function host(HTTPRequest $request = null) return $_SERVER['HTTP_HOST']; } - // Check base url + // Check default_base_url if ($baseURL = self::config()->uninherited('default_base_url')) { $baseURL = Injector::inst()->convertServiceProperty($baseURL); $host = static::parseHost($baseURL); @@ -565,6 +565,15 @@ public static function host(HTTPRequest $request = null) } } + // Check BASE_URL environment variable + if ($baseURL = BASE_URL) { + $baseURL = Injector::inst()->convertServiceProperty($baseURL); + $host = static::parseHost($baseURL); + if ($host) { + return $host; + } + } + // Fail over to server_name (least reliable) return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : gethostname(); }