diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index b0c6680d9..6ccca4793 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -46,6 +46,9 @@ public function resources() if (!$environment) { return redirect()->route('dashboard'); } - return view('project.resources', ['project' => $project, 'environment' => $environment]); + return view('project.resources', [ + 'project' => $project, + 'environment' => $environment + ]); } } diff --git a/app/Http/Livewire/Project/Application/General.php b/app/Http/Livewire/Project/Application/General.php index 0b551e55f..b9b14cb18 100644 --- a/app/Http/Livewire/Project/Application/General.php +++ b/app/Http/Livewire/Project/Application/General.php @@ -73,7 +73,11 @@ public function mount() } public function submit() { - $this->validate(); - $this->application->save(); + try { + $this->validate(); + $this->application->save(); + } catch (\Exception $e) { + return generalErrorHandler($e, $this); + } } } diff --git a/app/Jobs/DeployApplicationJob.php b/app/Jobs/DeployApplicationJob.php index 1b8dce612..243101863 100644 --- a/app/Jobs/DeployApplicationJob.php +++ b/app/Jobs/DeployApplicationJob.php @@ -383,9 +383,11 @@ private function set_labels_for_applications() $path = $url->getPath(); $labels[] = 'traefik.enable=true'; if ($path === '/') { - $labels[] = "traefik.http.routers.container.rule=Host(`{$host}`) && PathPrefix(`{$path}`)"; + $labels[] = "traefik.http.routers.{$this->application->uuid}.rule=Host(`{$host}`) && Path(`{$path}`)"; } else { - $labels[] = "traefik.http.routers.container.rule=Host(`{$host}`) && PathPrefix(`{$path}`)"; + $labels[] = "traefik.http.routers.{$this->application->uuid}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)"; + $labels[] = "traefik.http.routers.{$this->application->uuid}.middlewares={$this->application->uuid}-stripprefix"; + $labels[] = "traefik.http.middlewares.{$this->application->uuid}-stripprefix.stripprefix.prefixes={$path}"; } } return $labels; diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php index 5d26fc05b..9067a3dd4 100644 --- a/bootstrap/helpers.php +++ b/bootstrap/helpers.php @@ -33,7 +33,7 @@ function generalErrorHandler(\Throwable $e, $that = null, $isJson = false) } } catch (\Throwable $error) { if ($that) { - $that->emit('error', $error->getMessage()); + return $that->emit('error', $error->getMessage()); } elseif ($isJson) { return response()->json([ 'code' => $error->getCode(), diff --git a/resources/views/project/resources.blade.php b/resources/views/project/resources.blade.php index f30907103..0df8ac7a6 100644 --- a/resources/views/project/resources.blade.php +++ b/resources/views/project/resources.blade.php @@ -6,8 +6,8 @@ @if ($environment->applications->count() === 0)

No resources yet.

@endif -
- @foreach ($environment->applications as $application) +
+ @foreach ($environment->applications->sortBy('name') as $application) {{ $application->name }}