#!/usr/bin/env php getMessage()}\n"); exit(1); } if (!isset($data['domains']) || !is_array($data['domains'])) { fwrite(STDERR, "Expected a \"domains\" array in $jsonFile\n"); exit(1); } $domains = []; foreach ($data['domains'] as $entry) { $host = is_array($entry) ? ($entry['domain'] ?? null) : $entry; $host = is_string($host) ? trim($host) : ''; if ($host === '') { continue; } if (!preg_match('/^[a-z0-9.-]+$/i', $host)) { fwrite(STDERR, "Skipping invalid domain: \"$host\"\n"); continue; } $domains[strtolower($host)] = true; // dedupe, case-insensitive } $domains = array_keys($domains); sort($domains); if (empty($domains)) { fwrite(STDERR, "No valid domains found in $jsonFile\n"); exit(1); } // Frontend hosts: bare hostnames, comma-separated. Drives both the CORS regex // (CorsRegexEnvProcessor) and PaymentController host validation. $hosts = implode(',', $domains); echo "# ---- paste into Coolify env (" . count($domains) . " domains) ----\n\n"; echo "ALLOWED_FRONTEND_HOSTS=" . $hosts . "\n";