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 preview domain generation for services with multiple domains
Andras Bacsaicdf6b5f16113
diff --git a/app/Livewire/Project/Application/PreviewsCompose.php b/app/Livewire/Project/Application/PreviewsCompose.phpindex e312497242..942dfeb379 100644--- a/app/Livewire/Project/Application/PreviewsCompose.php+++ b/app/Livewire/Project/Application/PreviewsCompose.php@@ -75,18 +75,32 @@ class PreviewsCompose extends Component$preview_fqdn = str($generated_fqdn)->before('://').'://'.$preview_fqdn;} else {// Use the existing domain from the main application- $url = Url::fromString($domain_string);+ // Handle multiple domains separated by commas+ $domain_list = explode(',', $domain_string);+ $preview_fqdns = [];$template = $this->preview->application->preview_url_template;- $host = $url->getHost();- $schema = $url->getScheme();- $portInt = $url->getPort();- $port = $portInt !== null ? ':'.$portInt : '';$random = new Cuid2;- $preview_fqdn = str_replace('{{random}}', $random, $template);- $preview_fqdn = str_replace('{{domain}}', $host, $preview_fqdn);- $preview_fqdn = str_replace('{{pr_id}}', $this->preview->pull_request_id, $preview_fqdn);- $preview_fqdn = str_replace('{{port}}', $port, $preview_fqdn);- $preview_fqdn = "$schema://$preview_fqdn";++ foreach ($domain_list as $single_domain) {+ $single_domain = trim($single_domain);+ if (empty($single_domain)) {+ continue;+ }++ $url = Url::fromString($single_domain);+ $host = $url->getHost();+ $schema = $url->getScheme();+ $portInt = $url->getPort();+ $port = $portInt !== null ? ':'.$portInt : '';++ $preview_fqdn = str_replace('{{random}}', $random, $template);+ $preview_fqdn = str_replace('{{domain}}', $host, $preview_fqdn);+ $preview_fqdn = str_replace('{{pr_id}}', $this->preview->pull_request_id, $preview_fqdn);+ $preview_fqdn = str_replace('{{port}}', $port, $preview_fqdn);+ $preview_fqdns[] = "$schema://$preview_fqdn";+ }++ $preview_fqdn = implode(',', $preview_fqdns);}// Save the generated domaindiff --git a/resources/views/livewire/project/application/previews-compose.blade.php b/resources/views/livewire/project/application/previews-compose.blade.phpindex 6faae3e972..ae8d702438 100644--- a/resources/views/livewire/project/application/previews-compose.blade.php+++ b/resources/views/livewire/project/application/previews-compose.blade.php@@ -1,7 +1,7 @@<form wire:submit="save" class="flex items-end gap-2">- <x-forms.input helper="One domain per preview." label="Domains for {{ str($serviceName)->headline() }}"- id="domain" canGate="update" :canResource="$preview->application"></x-forms.input>+ <x-forms.input helper="One domain per preview." label="Domains for {{ str($serviceName)->headline() }}" id="domain"+ canGate="update" :canResource="$preview->application"></x-forms.input><x-forms.button type="submit">Save</x-forms.button><x-forms.button wire:click="generate">GenerateDomain</x-forms.button>-</form>+</form>\ No newline at end of file