feat: dynamische APP_URL detectie voor dev.fociz.nl en fociz.nl, verwijder alle uw-domein placeholders

This commit is contained in:
2026-09-08 15:04:12 +02:00
parent 0d92e46e6d
commit 3e41915ee0
4 changed files with 32 additions and 6 deletions
+27 -2
View File
@@ -73,11 +73,36 @@ define('DB_USER', fociz_env('DB_USER', 'root'));
define('DB_PASS', fociz_env('DB_PASS', ''));
define('DB_CHARSET', 'utf8mb4');
// Bepaal de dynamische of geconfigureerde applicatie URL
if (!function_exists('fociz_detect_app_url')) {
function fociz_detect_app_url(): string {
$envUrl = fociz_env('APP_URL');
if (!empty($envUrl) && !str_contains($envUrl, 'uw-domein.nl')) {
return rtrim($envUrl, '/');
}
// Dynamische detectie op basis van het huidige domein (werkt direct op dev.fociz.nl én fociz.nl)
if (!empty($_SERVER['HTTP_HOST'])) {
$isHttps = (
(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ||
(!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https') ||
(!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] === 'on') ||
(isset($_SERVER['SERVER_PORT']) && (int)$_SERVER['SERVER_PORT'] === 443)
);
$scheme = $isHttps ? 'https://' : 'http://';
return $scheme . $_SERVER['HTTP_HOST'];
}
// Standaard fallback per omgeving
return (defined('APP_ENV') && APP_ENV === 'live') ? 'https://fociz.nl' : 'https://dev.fociz.nl';
}
}
// Applicatie instellingen
define('APP_NAME', 'Fociz');
define('APP_URL', fociz_env('APP_URL', ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://') . ($_SERVER['HTTP_HOST'] ?? 'localhost'))));
define('APP_SECRET', fociz_env('APP_SECRET', 'fociz-maria-db-super-secret-key-998877'));
define('APP_ENV', fociz_env('APP_ENV', 'development')); // 'development' of 'live'
define('APP_URL', fociz_detect_app_url());
define('APP_SECRET', fociz_env('APP_SECRET', 'fociz-maria-db-super-secret-key-998877'));
// Tijdzone
date_default_timezone_set('Europe/Amsterdam');