diff --git a/app/Console/Commands/MigrateEnvReverb.php b/app/Console/Commands/MigrateEnvReverb.php index 9997976..f91b217 100644 --- a/app/Console/Commands/MigrateEnvReverb.php +++ b/app/Console/Commands/MigrateEnvReverb.php @@ -19,12 +19,19 @@ class MigrateEnvReverb extends Command $content = file_get_contents($env); - // APP_HOST ermitteln – Fallback auf APP_URL + // APP_HOST ermitteln: .env → APP_URL → DB-Setting ui_domain $appHost = $this->extractVar($content, 'APP_HOST'); - if (!$appHost) { + if (!$appHost || preg_match('/^\d+\.\d+\.\d+\.\d+$/', $appHost)) { $appUrl = $this->extractVar($content, 'APP_URL'); $appHost = parse_url($appUrl ?: '', PHP_URL_HOST) ?: ''; } + if (!$appHost || preg_match('/^\d+\.\d+\.\d+\.\d+$/', $appHost)) { + try { + $appHost = (string) \App\Models\Setting::get('ui_domain', ''); + } catch (\Throwable) { + $appHost = ''; + } + } if (!$appHost || preg_match('/^\d+\.\d+\.\d+\.\d+$/', $appHost)) { $this->warn('Kein gültiger Hostname gefunden – Migration übersprungen.'); @@ -63,8 +70,23 @@ class MigrateEnvReverb extends Command } } + // APP_HOST setzen falls fehlend + if (!$this->extractVar($content, 'APP_HOST')) { + $content .= "\nAPP_HOST={$appHost}"; + } + file_put_contents($env, $content); $this->info("REVERB .env migriert für Host: {$appHost}"); + + // Assets neu bauen damit wsHost korrekt eingebacken wird + $buildLog = base_path('../mailwolt-frontend-build.log'); + exec('cd ' . escapeshellarg(base_path()) . ' && npm run build --silent 2>/dev/null', $out, $rc); + if ($rc !== 0) { + $this->warn('npm run build fehlgeschlagen – bitte manuell ausführen.'); + } else { + $this->info('Assets neu gebaut.'); + } + return self::SUCCESS; }