diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php
index 23bd94fb2..0f6d61957 100644
--- a/app/Livewire/Project/Application/General.php
+++ b/app/Livewire/Project/Application/General.php
@@ -245,9 +245,10 @@ class General extends Component
$domains = $domains->unique();
foreach ($domains as $domain) {
if (!validate_dns_entry($domain, $this->application->destination->server)) {
- $showToaster && $this->dispatch('error', "Validating DNS settings for: $domain failed. Make sure you have added the DNS records correctly.
Check this documentation for further help.");
+ $showToaster && $this->dispatch('error', "Validating DNS ($domain) failed.","Make sure you have added the DNS records correctly.
Check this documentation for further help.");
}
}
+ check_fqdn_usage($this->application);
$this->application->fqdn = $domains->implode(',');
}
diff --git a/app/Livewire/Project/Service/Application.php b/app/Livewire/Project/Service/Application.php
index 3ff711400..c3157921b 100644
--- a/app/Livewire/Project/Service/Application.php
+++ b/app/Livewire/Project/Service/Application.php
@@ -53,6 +53,7 @@ class Application extends Component
public function submit()
{
try {
+ check_fqdn_usage($this->application);
$this->validate();
$this->application->save();
updateCompose($this->application);
diff --git a/app/Models/Application.php b/app/Models/Application.php
index 9e9626ec2..e6b3309f1 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -1116,4 +1116,12 @@ class Application extends BaseModel
$this->save();
return $customLabels;
}
+ public function fqdns(): Attribute
+ {
+ return Attribute::make(
+ get: fn () => is_null($this->fqdn)
+ ? []
+ : explode(',', $this->fqdn),
+ );
+ }
}
diff --git a/app/Models/ServiceApplication.php b/app/Models/ServiceApplication.php
index 510395266..dff791da1 100644
--- a/app/Models/ServiceApplication.php
+++ b/app/Models/ServiceApplication.php
@@ -55,7 +55,6 @@ class ServiceApplication extends BaseModel
get: fn () => is_null($this->fqdn)
? []
: explode(',', $this->fqdn),
-
);
}
public function getFilesFromServer(bool $isInit = false)
diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php
index 3cff9ba24..5123d8510 100644
--- a/bootstrap/helpers/shared.php
+++ b/bootstrap/helpers/shared.php
@@ -1660,3 +1660,33 @@ function ip_match($ip, $cidrs, &$match = null)
}
return false;
}
+function check_fqdn_usage(ServiceApplication|Application $own_resource)
+{
+ $domains = collect($own_resource->fqdns)->map(function ($domain) {
+ return Url::fromString($domain)->getHost();
+ });
+ $apps = Application::all();
+ foreach ($apps as $app) {
+ $list_of_domains = collect(explode(',', $app->fqdn))->filter(fn ($fqdn) => $fqdn !== '');
+ foreach ($list_of_domains as $domain) {
+ $naked_domain = Url::fromString($domain)->getHost();
+ if ($domains->contains($naked_domain)) {
+ if ($app->uuid !== $own_resource->uuid ) {
+ throw new \RuntimeException("Domain $naked_domain is already in use by another resource.");
+ }
+ }
+ }
+ }
+ $apps = ServiceApplication::all();
+ foreach ($apps as $app) {
+ $list_of_domains = collect(explode(',', $app->fqdn))->filter(fn ($fqdn) => $fqdn !== '');
+ foreach ($list_of_domains as $domain) {
+ $naked_domain = Url::fromString($domain)->getHost();
+ if ($domains->contains($naked_domain)) {
+ if ($app->uuid !== $own_resource->uuid) {
+ throw new \RuntimeException("Domain $naked_domain is already in use by another resource.");
+ }
+ }
+ }
+ }
+}
diff --git a/resources/views/components/toast.blade.php b/resources/views/components/toast.blade.php
index 90cdb26e8..f28bbc5eb 100644
--- a/resources/views/components/toast.blade.php
+++ b/resources/views/components/toast.blade.php
@@ -369,14 +369,14 @@ window.customToastHTML = `
}, 5);
}, 4000);"
@mouseover="toastHovered=true" @mouseout="toastHovered=false"
- class="absolute w-full duration-300 ease-out select-none sm:max-w-xs"
+ class="absolute w-full duration-200 ease-out select-none sm:max-w-xs"
:class="{ 'toast-no-description': !toast.description }">