From 654e817ea1e664226f2380544d7cc47a8f679b9c Mon Sep 17 00:00:00 2001 From: rob Date: Fri, 19 Apr 2024 17:51:48 +0200 Subject: [PATCH 1/2] Add local_domains array to Clockwork configuration --- Clockwork/Support/Laravel/config/clockwork.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Clockwork/Support/Laravel/config/clockwork.php b/Clockwork/Support/Laravel/config/clockwork.php index 6f0a647..0cdfc89 100644 --- a/Clockwork/Support/Laravel/config/clockwork.php +++ b/Clockwork/Support/Laravel/config/clockwork.php @@ -15,6 +15,18 @@ 'enable' => env('CLOCKWORK_ENABLE', null), + /* + |------------------------------------------------------------------------------------------------------------------ + | Local Domains + |------------------------------------------------------------------------------------------------------------------ + | + | Here you can specify the domains that Clockwork considers as "local". Clockwork will only run on these domains + | unless explicitly enabled. + | + */ + + 'local_domains' => ['localhost', 'locl', 'local', 'test', 'wip'], + /* |------------------------------------------------------------------------------------------------------------------ | Features From 6559ef8976fd08d9c7c3ea15960b0fe0c40afd50 Mon Sep 17 00:00:00 2001 From: rob Date: Fri, 19 Apr 2024 17:55:16 +0200 Subject: [PATCH 2/2] Update hasLocalHost function to use local_domains from config --- Clockwork/Request/IncomingRequest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Clockwork/Request/IncomingRequest.php b/Clockwork/Request/IncomingRequest.php index 9638849..865a934 100644 --- a/Clockwork/Request/IncomingRequest.php +++ b/Clockwork/Request/IncomingRequest.php @@ -41,8 +41,10 @@ public function hasLocalHost() { $segments = explode('.', $this->host); $tld = $segments[count($segments) - 1]; + $local_domains = config('clockwork.local_domains') ?? ['localhost', 'locl', 'local', 'test', 'wip']; + + return $this->host == '127.0.0.1' || + in_array($tld, $local_domains); - return $this->host == '127.0.0.1' - || in_array($tld, [ 'localhost', 'local', 'test', 'wip' ]); } }