Skip to content

Commit b31a3c2

Browse files
authored
Merge branch 'next' into feat/sparkyfitness
2 parents 52333ef + 1a7671f commit b31a3c2

File tree

16 files changed

+827
-63
lines changed

16 files changed

+827
-63
lines changed

app/Http/Middleware/TrustHosts.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,42 @@
44

55
use App\Models\InstanceSettings;
66
use Illuminate\Http\Middleware\TrustHosts as Middleware;
7+
use Illuminate\Http\Request;
78
use Illuminate\Support\Facades\Cache;
89
use Spatie\Url\Url;
910

1011
class TrustHosts extends Middleware
1112
{
13+
/**
14+
* Handle the incoming request.
15+
*
16+
* Skip host validation for certain routes:
17+
* - Terminal auth routes (called by realtime container)
18+
* - API routes (use token-based authentication, not host validation)
19+
* - Webhook endpoints (use cryptographic signature validation)
20+
*/
21+
public function handle(Request $request, $next)
22+
{
23+
// Skip host validation for these routes
24+
if ($request->is(
25+
'terminal/auth',
26+
'terminal/auth/ips',
27+
'api/*',
28+
'webhooks/*'
29+
)) {
30+
return $next($request);
31+
}
32+
33+
// Skip host validation if no FQDN is configured (initial setup)
34+
$fqdnHost = Cache::get('instance_settings_fqdn_host');
35+
if ($fqdnHost === '' || $fqdnHost === null) {
36+
return $next($request);
37+
}
38+
39+
// For all other routes, use parent's host validation
40+
return parent::handle($request, $next);
41+
}
42+
1243
/**
1344
* Get the host patterns that should be trusted.
1445
*
@@ -44,6 +75,19 @@ public function hosts(): array
4475
$trustedHosts[] = $fqdnHost;
4576
}
4677

78+
// Trust the APP_URL host itself (not just subdomains)
79+
$appUrl = config('app.url');
80+
if ($appUrl) {
81+
try {
82+
$appUrlHost = parse_url($appUrl, PHP_URL_HOST);
83+
if ($appUrlHost && ! in_array($appUrlHost, $trustedHosts, true)) {
84+
$trustedHosts[] = $appUrlHost;
85+
}
86+
} catch (\Exception $e) {
87+
// Ignore parse errors
88+
}
89+
}
90+
4791
// Trust all subdomains of APP_URL as fallback
4892
$trustedHosts[] = $this->allSubdomainsOfApplicationUrl();
4993

app/Jobs/ApplicationDeploymentJob.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,10 @@ private function deploy_dockerimage_buildpack()
517517
$this->generate_image_names();
518518
$this->prepare_builder_image();
519519
$this->generate_compose_file();
520+
521+
// Save runtime environment variables (including empty .env file if no variables defined)
522+
$this->save_runtime_environment_variables();
523+
520524
$this->rolling_update();
521525
}
522526

@@ -1222,9 +1226,9 @@ private function save_runtime_environment_variables()
12221226

12231227
// Handle empty environment variables
12241228
if ($environment_variables->isEmpty()) {
1225-
// For Docker Compose, we need to create an empty .env file
1229+
// For Docker Compose and Docker Image, we need to create an empty .env file
12261230
// because we always reference it in the compose file
1227-
if ($this->build_pack === 'dockercompose') {
1231+
if ($this->build_pack === 'dockercompose' || $this->build_pack === 'dockerimage') {
12281232
$this->application_deployment_queue->addLogEntry('Creating empty .env file (no environment variables defined).');
12291233

12301234
// Create empty .env file

app/Livewire/Project/Service/EditDomain.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function submit()
8383
$this->validate();
8484
$this->application->save();
8585
$this->application->refresh();
86-
$this->syncData(false);
86+
$this->syncFromModel();
8787
updateCompose($this->application);
8888
if (str($this->application->fqdn)->contains(',')) {
8989
$this->dispatch('warning', 'Some services do not support multiple domains, which can lead to problems and is NOT RECOMMENDED.<br><br>Only use multiple domains if you know what you are doing.');
@@ -96,7 +96,7 @@ public function submit()
9696
$originalFqdn = $this->application->getOriginal('fqdn');
9797
if ($originalFqdn !== $this->application->fqdn) {
9898
$this->application->fqdn = $originalFqdn;
99-
$this->syncData(false);
99+
$this->syncFromModel();
100100
}
101101

102102
return handleError($e, $this);

config/constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
return [
44
'coolify' => [
5-
'version' => '4.0.0-beta.436',
5+
'version' => '4.0.0-beta.438',
66
'helper_version' => '1.0.11',
77
'realtime_version' => '1.0.10',
88
'self_hosted' => env('SELF_HOSTED', true),

0 commit comments

Comments
 (0)