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(deployment): refactor domain parsing and environment variable generation using Spatie URL library
Andras Bacsai94f9c5425609
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.phpindex 109c728848..c31a64fa10 100644--- a/app/Jobs/ApplicationDeploymentJob.php+++ b/app/Jobs/ApplicationDeploymentJob.php@@ -30,6 +30,7 @@ use Illuminate\Support\Collection;use Illuminate\Support\Sleep;use Illuminate\Support\Str;use RuntimeException;+use Spatie\Url\Url;use Symfony\Component\Yaml\Yaml;use Throwable;use Visus\Cuid2\Cuid2;@@ -933,10 +934,12 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue$parsedDomain = data_get($domain, 'domain');if (filled($parsedDomain)) {$parsedDomain = str($parsedDomain)->explode(',')->first();- $coolifyUrl = str($parsedDomain)->after('://')->before(':')->prepend(str($parsedDomain)->before('://')->append('://'));- $coolifyFqdn = str($parsedDomain)->replace('http://', '')->replace('https://', '')->before(':');- $envs->push('SERVICE_URL_'.str($forServiceName)->upper().'='.$coolifyUrl->value());- $envs->push('SERVICE_FQDN_'.str($forServiceName)->upper().'='.$coolifyFqdn->value());+ $coolifyUrl = Url::fromString($parsedDomain);+ $coolifyScheme = $coolifyUrl->getScheme();+ $coolifyFqdn = $coolifyUrl->getHost();+ $coolifyUrl = $coolifyUrl->withScheme($coolifyScheme)->withHost($coolifyFqdn)->withPort(null);+ $envs->push('SERVICE_URL_'.str($forServiceName)->upper().'='.$coolifyUrl->__toString());+ $envs->push('SERVICE_FQDN_'.str($forServiceName)->upper().'='.$coolifyFqdn);}}}@@ -964,10 +967,12 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue$parsedDomain = data_get($domain, 'domain');if (filled($parsedDomain)) {$parsedDomain = str($parsedDomain)->explode(',')->first();- $coolifyUrl = str($parsedDomain)->after('://')->before(':')->prepend(str($parsedDomain)->before('://')->append('://'));- $coolifyFqdn = str($parsedDomain)->replace('http://', '')->replace('https://', '')->before(':');- $envs->push('SERVICE_URL_'.str($forServiceName)->upper().'='.$coolifyUrl->value());- $envs->push('SERVICE_FQDN_'.str($forServiceName)->upper().'='.$coolifyFqdn->value());+ $coolifyUrl = Url::fromString($parsedDomain);+ $coolifyScheme = $coolifyUrl->getScheme();+ $coolifyFqdn = $coolifyUrl->getHost();+ $coolifyUrl = $coolifyUrl->withScheme($coolifyScheme)->withHost($coolifyFqdn)->withPort(null);+ $envs->push('SERVICE_URL_'.str($forServiceName)->upper().'='.$coolifyUrl->__toString());+ $envs->push('SERVICE_FQDN_'.str($forServiceName)->upper().'='.$coolifyFqdn);}}}diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.phpindex e62185cc11..00a674eeb8 100644--- a/bootstrap/helpers/shared.php+++ b/bootstrap/helpers/shared.php@@ -3670,10 +3670,12 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int$parsedDomain = data_get($domain, 'domain');if (filled($parsedDomain)) {$parsedDomain = str($parsedDomain)->explode(',')->first();- $coolifyUrl = str($parsedDomain)->after('://')->before(':')->prepend(str($parsedDomain)->before('://')->append('://'));- $coolifyFqdn = str($parsedDomain)->replace('http://', '')->replace('https://', '')->before(':');- $coolifyEnvironments->put('SERVICE_URL_'.str($forServiceName)->upper(), $coolifyUrl->value());- $coolifyEnvironments->put('SERVICE_FQDN_'.str($forServiceName)->upper(), $coolifyFqdn->value());+ $coolifyUrl = Url::fromString($parsedDomain);+ $coolifyScheme = $coolifyUrl->getScheme();+ $coolifyFqdn = $coolifyUrl->getHost();+ $coolifyUrl = $coolifyUrl->withScheme($coolifyScheme)->withHost($coolifyFqdn)->withPort(null);+ $coolifyEnvironments->put('SERVICE_URL_'.str($forServiceName)->upper(), $coolifyUrl->__toString());+ $coolifyEnvironments->put('SERVICE_FQDN_'.str($forServiceName)->upper(), $coolifyFqdn);}}}