From de4e74b4cd8aaaf323fcea5c102d3b1046ac0a18 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Fri, 7 Aug 2026 15:41:39 +0200 Subject: [PATCH] feat(server): fall back Sentinel URL to request host Use the current request scheme/host when no FQDN or public IP is set, skipping loopback hosts. Polish boarding/server create cards, optional listbox tooltips, and cover the layout and Sentinel URL behavior in tests. --- app/Models/ServerSetting.php | 27 +++++- .../views/components/forms/listbox.blade.php | 3 +- .../views/livewire/boarding/index.blade.php | 84 +++++++------------ .../views/livewire/server/create.blade.php | 23 +---- .../views/livewire/server/index.blade.php | 11 +-- .../server/new/by-digital-ocean.blade.php | 12 ++- .../views/livewire/server/new/by-ip.blade.php | 2 +- .../livewire/server/new/by-vultr.blade.php | 12 ++- tests/Feature/BoardingActionsLayoutTest.php | 58 +++++++++++++ tests/Feature/SentinelTokenValidationTest.php | 36 ++++++++ tests/Feature/ServerCreatePageLayoutTest.php | 10 +++ .../ServerCreationBuildRoleLayoutTest.php | 1 + tests/Feature/ServerIndexViewSwitcherTest.php | 10 +++ .../StartSentinelEndpointFallbackTest.php | 3 +- 14 files changed, 203 insertions(+), 89 deletions(-) diff --git a/app/Models/ServerSetting.php b/app/Models/ServerSetting.php index 3bd39aeb1..93f040e4a 100644 --- a/app/Models/ServerSetting.php +++ b/app/Models/ServerSetting.php @@ -228,7 +228,7 @@ class ServerSetting extends Model } if (blank($url)) { - throw new \RuntimeException('Set an instance FQDN or public IP before enabling Sentinel.'); + throw new \RuntimeException('Set an instance FQDN, public IP, or reachable Coolify URL before enabling Sentinel.'); } return $url; @@ -246,6 +246,8 @@ class ServerSetting extends Model $domain = 'http://'.$settings->public_ipv4.':8000'; } elseif ($settings->public_ipv6) { $domain = 'http://'.$settings->public_ipv6.':8000'; + } else { + $domain = $this->sentinelUrlFromCurrentRequest(); } $this->sentinel_custom_url = $domain; if ($save) { @@ -259,6 +261,29 @@ class ServerSetting extends Model return $domain; } + private function sentinelUrlFromCurrentRequest(): ?string + { + if (! app()->bound('request')) { + return null; + } + + $request = request(); + $host = strtolower($request->getHost()); + + if ( + $host === 'localhost' || + str_ends_with($host, '.localhost') || + $host === '::1' || + $host === '::' || + $host === '0.0.0.0' || + str_starts_with($host, '127.') + ) { + return null; + } + + return $request->getSchemeAndHttpHost(); + } + public function server() { return $this->belongsTo(Server::class); diff --git a/resources/views/components/forms/listbox.blade.php b/resources/views/components/forms/listbox.blade.php index eb32de577..050bea8b3 100644 --- a/resources/views/components/forms/listbox.blade.php +++ b/resources/views/components/forms/listbox.blade.php @@ -11,6 +11,7 @@ 'wire' => true, // false = purely client-side value (no Livewire binding) 'value' => null, // initial value when wire=false 'disabled' => false, + 'tooltip' => true, ])