Skip to content

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.

Refactor proxy type retrieval in Server and Proxy classes

Andras Bacsai4d181eef8ee4
diff --git a/app/Livewire/Server/Proxy.php b/app/Livewire/Server/Proxy.php
index 4ccbf7d64b..dab7f54bed 100644
--- a/app/Livewire/Server/Proxy.php
+++ b/app/Livewire/Server/Proxy.php
@@ -21,7 +21,7 @@ class Proxy extends Component
public function mount()
{
- $this->selectedProxy = data_get($this->server, 'proxy.type');
+ $this->selectedProxy = $this->server->proxyType();
$this->redirect_url = data_get($this->server, 'proxy.redirect_url');
}
diff --git a/app/Models/Server.php b/app/Models/Server.php
index f361adc7b5..c632520a19 100644
--- a/app/Models/Server.php
+++ b/app/Models/Server.php
@@ -400,7 +400,7 @@ $schema://$host {
// $this->proxy->status = ProxyStatus::EXITED->value;
// $this->save();
// }
- return data_get($this->proxy, 'type.type');
+ return data_get($this->proxy, 'type');
}
public function scopeWithProxy(): Builder
{
diff --git a/resources/views/livewire/server/proxy.blade.php b/resources/views/livewire/server/proxy.blade.php
index 49bf654a6c..f2d9b839e4 100644
--- a/resources/views/livewire/server/proxy.blade.php
+++ b/resources/views/livewire/server/proxy.blade.php
@@ -1,5 +1,5 @@
<div>
- @if (data_get($server, 'proxy.type'))
+ @if ($server->proxyType())
<div x-init="$wire.loadProxyConfiguration">
@if ($selectedProxy !== 'NONE')
<form wire:submit='submit'>
@@ -13,10 +13,11 @@
<x-forms.button type="submit">Save</x-forms.button>
</div>
- <div class="pb-4 "> <svg class="inline-flex w-6 h-6 mr-2 text-warning" viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg">
- <path fill="currentColor"
- d="M240.26 186.1L152.81 34.23a28.74 28.74 0 0 0-49.62 0L15.74 186.1a27.45 27.45 0 0 0 0 27.71A28.31 28.31 0 0 0 40.55 228h174.9a28.31 28.31 0 0 0 24.79-14.19a27.45 27.45 0 0 0 .02-27.71m-20.8 15.7a4.46 4.46 0 0 1-4 2.2H40.55a4.46 4.46 0 0 1-4-2.2a3.56 3.56 0 0 1 0-3.73L124 46.2a4.77 4.77 0 0 1 8 0l87.44 151.87a3.56 3.56 0 0 1 .02 3.73M116 136v-32a12 12 0 0 1 24 0v32a12 12 0 0 1-24 0m28 40a16 16 0 1 1-16-16a16 16 0 0 1 16 16" />
- </svg>Before switching proxies, please read <a class="text-white underline"
+ <div class="pb-4 "> <svg class="inline-flex w-6 h-6 mr-2 text-warning" viewBox="0 0 256 256"
+ xmlns="http://www.w3.org/2000/svg">
+ <path fill="currentColor"
+ d="M240.26 186.1L152.81 34.23a28.74 28.74 0 0 0-49.62 0L15.74 186.1a27.45 27.45 0 0 0 0 27.71A28.31 28.31 0 0 0 40.55 228h174.9a28.31 28.31 0 0 0 24.79-14.19a27.45 27.45 0 0 0 .02-27.71m-20.8 15.7a4.46 4.46 0 0 1-4 2.2H40.55a4.46 4.46 0 0 1-4-2.2a3.56 3.56 0 0 1 0-3.73L124 46.2a4.77 4.77 0 0 1 8 0l87.44 151.87a3.56 3.56 0 0 1 .02 3.73M116 136v-32a12 12 0 0 1 24 0v32a12 12 0 0 1-24 0m28 40a16 16 0 1 1-16-16a16 16 0 0 1 16 16" />
+ </svg>Before switching proxies, please read <a class="text-white underline"
href="https://coolify.io/docs/server/switching-proxies">this</a>.</div>
@if ($server->proxyType() === 'TRAEFIK_V2')
<div class="pb-4">Traefik v2</div>
diff --git a/resources/views/livewire/server/proxy/deploy.blade.php b/resources/views/livewire/server/proxy/deploy.blade.php
index 7a27eeab32..85652c982e 100644
--- a/resources/views/livewire/server/proxy/deploy.blade.php
+++ b/resources/views/livewire/server/proxy/deploy.blade.php
@@ -16,10 +16,10 @@
</p>
</x-slot:modalBody>
</x-modal>
- @if ($server->isFunctional() && data_get($server, 'proxy.type') !== 'NONE')
+ @if ($server->isFunctional() && $server->proxyType() !== 'NONE')
@if (data_get($server, 'proxy.status') === 'running')
<div class="flex gap-4">
- @if ($currentRoute === 'server.proxy' && $traefikDashboardAvailable)
+ @if ($currentRoute === 'server.proxy' && $traefikDashboardAvailable && $server->proxyType() === 'TRAEFIK_V2')
<button>
<a target="_blank" href="http://{{ $serverIp }}:8080">
Traefik Dashboard