Skip to content

Commit

Permalink
Ensure isn't checked during RouteCollection calls when called from CLI.
Browse files Browse the repository at this point in the history
Fixes #1724
  • Loading branch information
lonnieezell committed Feb 17, 2019
1 parent 6bf6403 commit b4df000
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/Config/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
// route since we don't have to scan directories.
$routes->get('/', 'Home::index');

$routes->get('foo', 'Home::index', ['hostname' => 'foobar.com']);

/**
* --------------------------------------------------------------------
* Additional Routing
Expand Down
8 changes: 7 additions & 1 deletion system/Router/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit b4df000

Please sign in to comment.