diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 4083ca39b156..2d8c4c8aa69f 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1250,7 +1250,7 @@ protected function create(string $verb, string $from, $to, array $options = null if (! empty($options['hostname'])) { // @todo determine if there's a way to whitelist hosts? - if (strtolower($_SERVER['HTTP_HOST']) !== strtolower($options['hostname'])) + if (isset($_SERVER['HTTP_HOST']) && strtolower($_SERVER['HTTP_HOST']) !== strtolower($options['hostname'])) { return; } @@ -1347,6 +1347,12 @@ protected function create(string $verb, string $from, $to, array $options = null */ private function checkSubdomains($subdomains) { + // CLI calls can't be on subdomain. + if (! isset($_SERVER['HTTP_HOST'])) + { + return false; + } + if (is_null($this->currentSubdomain)) { $this->currentSubdomain = $this->determineCurrentSubdomain();