An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(dns): skip auto DNS jobs when server IP is invalid
Andras Bacsai27bb601e6671
diff --git a/app/Livewire/Concerns/InteractsWithDnsProviders.php b/app/Livewire/Concerns/InteractsWithDnsProviders.phpindex 493c6fe22d..59cb352f9e 100644--- a/app/Livewire/Concerns/InteractsWithDnsProviders.php+++ b/app/Livewire/Concerns/InteractsWithDnsProviders.php@@ -83,6 +83,9 @@ trait InteractsWithDnsProvidersif ($this->dnsProviderProposals === []) {return false;}+ if (blank($this->serverIp) || filter_var($this->serverIp, FILTER_VALIDATE_IP) === false) {+ return false;+ }$this->markDnsPending($hostnames);$proposalsByHostname = collect($this->dnsProviderProposals)->groupBy('hostname');diff --git a/tests/Feature/ApplicationDomainsTest.php b/tests/Feature/ApplicationDomainsTest.phpindex 2c8ea4fe51..5196baadef 100644--- a/tests/Feature/ApplicationDomainsTest.php+++ b/tests/Feature/ApplicationDomainsTest.php@@ -1,13 +1,16 @@<?phpuse App\Jobs\CheckDomainDnsJob;+use App\Jobs\ConfigureDnsRecordJob;use App\Livewire\Project\Application\Domains;use App\Livewire\Project\Application\PreviewDomains;use App\Livewire\Project\Application\Previews;use App\Models\Application;use App\Models\ApplicationPreview;+use App\Models\DnsProviderZone;use App\Models\Environment;use App\Models\InstanceSettings;+use App\Models\IntegrationToken;use App\Models\Project;use App\Models\Server;use App\Models\StandaloneDocker;@@ -821,6 +824,52 @@ it('adds a domain to the application', function () {->toBe(['https://app.example.com', 'https://www.app.example.com']);});+it('dispatches configure dns jobs when a matching automatic zone and valid server ip exist', function () {+ Queue::fake();++ $token = IntegrationToken::factory()->for($this->team)->create([+ 'provider' => 'cloudflare',+ 'capabilities' => ['dns'],+ ]);+ DnsProviderZone::factory()->for($token)->create(['name' => 'example.com']);++ Livewire::test(Domains::class, ['application' => $this->application->fresh()])+ ->set('newDomain', 'https://app.example.com')+ ->call('addDomain')+ ->assertHasNoErrors()+ ->assertDispatched('success', 'Domain added.');++ Queue::assertPushed(ConfigureDnsRecordJob::class, 2);+ Queue::assertPushed(ConfigureDnsRecordJob::class, fn (ConfigureDnsRecordJob $job): bool => $job->hostname === 'app.example.com'+ && $job->content === '203.0.113.10'+ && $job->teamId === $this->team->id);+ Queue::assertPushed(ConfigureDnsRecordJob::class, fn (ConfigureDnsRecordJob $job): bool => $job->hostname === 'www.app.example.com'+ && $job->content === '203.0.113.10');+});++it('does not dispatch configure dns jobs when the server ip is missing or invalid', function () {+ Queue::fake();++ $this->server->update(['ip' => 'not-an-ip']);++ $token = IntegrationToken::factory()->for($this->team)->create([+ 'provider' => 'cloudflare',+ 'capabilities' => ['dns'],+ ]);+ DnsProviderZone::factory()->for($token)->create(['name' => 'example.com']);++ Livewire::test(Domains::class, ['application' => $this->application->fresh()])+ ->set('newDomain', 'https://app.example.com')+ ->call('addDomain')+ ->assertHasNoErrors()+ ->assertNotDispatched('error');++ expect(explode(',', (string) $this->application->fresh()->fqdn))+ ->toContain('https://app.example.com');++ Queue::assertNotPushed(ConfigureDnsRecordJob::class);+});+it('composes the complete port on the server without duplicating an existing www domain', function () {$this->application->update(['fqdn' => 'https://www.example.com:3000']);