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: apply frontend path normalization to general settings page
Andras Bacsai8714d9bd0332
diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.phpindex ef474fb027..56d45ae196 100644--- a/app/Livewire/Project/Application/General.php+++ b/app/Livewire/Project/Application/General.php@@ -606,13 +606,6 @@ class General extends Component}}- public function updatedBaseDirectory()- {- if ($this->buildPack === 'dockercompose') {- $this->loadComposeFile();- }- }-public function updatedIsStatic($value){if ($value) {@@ -791,6 +784,7 @@ class General extends Component$oldPortsExposes = $this->application->ports_exposes;$oldIsContainerLabelEscapeEnabled = $this->application->settings->is_container_label_escape_enabled;$oldDockerComposeLocation = $this->initialDockerComposeLocation;+ $oldBaseDirectory = $this->application->base_directory;// Process FQDN with intermediate variable to avoid Collection/string confusion$this->fqdn = str($this->fqdn)->replaceEnd(',', '')->trim()->toString();@@ -821,6 +815,16 @@ class General extends Componentreturn; // Stop if there are conflicts and user hasn't confirmed}+ // Normalize paths BEFORE validation+ if ($this->baseDirectory && $this->baseDirectory !== '/') {+ $this->baseDirectory = rtrim($this->baseDirectory, '/');+ $this->application->base_directory = $this->baseDirectory;+ }+ if ($this->publishDirectory && $this->publishDirectory !== '/') {+ $this->publishDirectory = rtrim($this->publishDirectory, '/');+ $this->application->publish_directory = $this->publishDirectory;+ }+$this->application->save();if (! $this->customLabels && $this->application->destination->server->proxyType() !== 'NONE' && ! $this->application->settings->is_container_label_readonly_enabled) {$this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n");@@ -828,7 +832,10 @@ class General extends Component$this->application->save();}- if ($this->buildPack === 'dockercompose' && $oldDockerComposeLocation !== $this->dockerComposeLocation) {+ // Validate docker compose file path when base directory OR compose location changes+ if ($this->buildPack === 'dockercompose' &&+ ($oldDockerComposeLocation !== $this->dockerComposeLocation ||+ $oldBaseDirectory !== $this->baseDirectory)) {$compose_return = $this->loadComposeFile(showToast: false);if ($compose_return instanceof \Livewire\Features\SupportEvents\Event) {return;@@ -855,14 +862,6 @@ class General extends Component$this->application->ports_exposes = $port;}}- if ($this->baseDirectory && $this->baseDirectory !== '/') {- $this->baseDirectory = rtrim($this->baseDirectory, '/');- $this->application->base_directory = $this->baseDirectory;- }- if ($this->publishDirectory && $this->publishDirectory !== '/') {- $this->publishDirectory = rtrim($this->publishDirectory, '/');- $this->application->publish_directory = $this->publishDirectory;- }if ($this->buildPack === 'dockercompose') {$this->application->docker_compose_domains = json_encode($this->parsedServiceDomains);if ($this->application->isDirty('docker_compose_domains')) {diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.phpindex d1a331d1a7..8cf46d2f3b 100644--- a/resources/views/livewire/project/application/general.blade.php+++ b/resources/views/livewire/project/application/general.blade.php@@ -241,12 +241,32 @@@else<div class="flex flex-col gap-2">@endcan- <div class="flex gap-2">- <x-forms.input x-bind:disabled="shouldDisable()" placeholder="/" id="baseDirectory"- label="Base Directory" helper="Directory to use as root. Useful for monorepos." />+ <div x-data="{+ baseDir: '{{ $application->base_directory }}',+ composeLocation: '{{ $application->docker_compose_location }}',+ normalizePath(path) {+ if (!path || path.trim() === '') return '/';+ path = path.trim();+ path = path.replace(/\/+$/, '');+ if (!path.startsWith('/')) {+ path = '/' + path;+ }+ return path;+ },+ normalizeBaseDir() {+ this.baseDir = this.normalizePath(this.baseDir);+ },+ normalizeComposeLocation() {+ this.composeLocation = this.normalizePath(this.composeLocation);+ }+ }" class="flex gap-2">+ <x-forms.input x-bind:disabled="shouldDisable()" placeholder="/" wire:model.defer="baseDirectory"+ label="Base Directory" helper="Directory to use as root. Useful for monorepos."+ x-model="baseDir" @blur="normalizeBaseDir()" /><x-forms.input x-bind:disabled="shouldDisable()" placeholder="/docker-compose.yaml"- id="dockerComposeLocation" label="Docker Compose Location"- helper="It is calculated together with the Base Directory:<br><span class='dark:text-warning'>{{ Str::start($application->base_directory . $application->docker_compose_location, '/') }}</span>" />+ wire:model.defer="dockerComposeLocation" label="Docker Compose Location"+ helper="It is calculated together with the Base Directory:<br><span class='dark:text-warning'>{{ Str::start($application->base_directory . $application->docker_compose_location, '/') }}</span>"+ x-model="composeLocation" @blur="normalizeComposeLocation()" /></div><div class="w-96"><x-forms.checkbox instantSave id="isPreserveRepositoryEnabled"@@ -293,13 +313,32 @@@endif</div>@else- <div class="flex flex-col gap-2 xl:flex-row">- <x-forms.input placeholder="/" id="baseDirectory" label="Base Directory"- helper="Directory to use as root. Useful for monorepos." x-bind:disabled="!canUpdate" />+ <div x-data="{+ baseDir: '{{ $application->base_directory }}',+ dockerfileLocation: '{{ $application->dockerfile_location }}',+ normalizePath(path) {+ if (!path || path.trim() === '') return '/';+ path = path.trim();+ path = path.replace(/\/+$/, '');+ if (!path.startsWith('/')) {+ path = '/' + path;+ }+ return path;+ },+ normalizeBaseDir() {+ this.baseDir = this.normalizePath(this.baseDir);+ },+ normalizeDockerfileLocation() {+ this.dockerfileLocation = this.normalizePath(this.dockerfileLocation);+ }+ }" class="flex flex-col gap-2 xl:flex-row">+ <x-forms.input placeholder="/" wire:model.defer="baseDirectory" label="Base Directory"+ helper="Directory to use as root. Useful for monorepos." x-bind:disabled="!canUpdate"+ x-model="baseDir" @blur="normalizeBaseDir()" />@if ($application->build_pack === 'dockerfile' && !$application->dockerfile)- <x-forms.input placeholder="/Dockerfile" id="dockerfileLocation" label="Dockerfile Location"+ <x-forms.input placeholder="/Dockerfile" wire:model.defer="dockerfileLocation" label="Dockerfile Location"helper="It is calculated together with the Base Directory:<br><span class='dark:text-warning'>{{ Str::start($application->base_directory . $application->dockerfile_location, '/') }}</span>"- x-bind:disabled="!canUpdate" />+ x-bind:disabled="!canUpdate" x-model="dockerfileLocation" @blur="normalizeDockerfileLocation()" />@endif@if ($application->build_pack === 'dockerfile')