Skip to content

Commit

Permalink
ENH Call baseURL() instead of just alternate_base_url
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Nov 21, 2021
1 parent d2cbf5b commit c4ce944
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Control/Director.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
}
Expand Down

0 comments on commit c4ce944

Please sign in to comment.