mirror of
https://git.hexahost.dev/smueller/HexaHost-Frontend.git
synced 2026-06-02 10:28:43 +00:00
Enhance configuration management: Updated README.md with Windows sync instructions, refactored backend configuration files to improve loading logic, and ensured consistent function definitions. Improved error handling in bootstrap.php for better user feedback during application startup.
This commit is contained in:
81
public/config/site-config.php
Normal file
81
public/config/site-config.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* HexaHost.de – zentrale Domain- und Umgebungskonfiguration
|
||||
*/
|
||||
|
||||
if (!defined('SITE_DOMAIN_PRODUCTION')) {
|
||||
define('SITE_DOMAIN_PRODUCTION', 'hexahost.de');
|
||||
}
|
||||
|
||||
if (!defined('SITE_DOMAIN_DEVELOPMENT')) {
|
||||
define('SITE_DOMAIN_DEVELOPMENT', 'dev.hexahost.de');
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktuellen HTTP-Host (ohne Port) ermitteln
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getSiteHost()
|
||||
{
|
||||
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : SITE_DOMAIN_PRODUCTION;
|
||||
$host = strtolower($host);
|
||||
|
||||
if (strpos($host, ':') !== false) {
|
||||
$host = explode(':', $host, 2)[0];
|
||||
}
|
||||
|
||||
return $host;
|
||||
}
|
||||
|
||||
/**
|
||||
* true, wenn die Seite unter der Dev-Domain läuft
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function isDevelopmentSite()
|
||||
{
|
||||
return getSiteHost() === SITE_DOMAIN_DEVELOPMENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Basis-URL der aktuellen Anfrage (Schema + Host)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getSiteBaseUrl()
|
||||
{
|
||||
$https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
|
||||
|| (isset($_SERVER['SERVER_PORT']) && (int) $_SERVER['SERVER_PORT'] === 443);
|
||||
|
||||
$scheme = $https ? 'https' : 'http';
|
||||
|
||||
return $scheme . '://' . getSiteHost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Erlaubte CORS-Origins für AJAX (Kontaktformular)
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
function getAllowedOrigins()
|
||||
{
|
||||
return [
|
||||
'https://' . SITE_DOMAIN_PRODUCTION,
|
||||
'https://www.' . SITE_DOMAIN_PRODUCTION,
|
||||
'https://' . SITE_DOMAIN_DEVELOPMENT,
|
||||
'http://localhost',
|
||||
'http://127.0.0.1',
|
||||
'http://localhost:8000',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Kanonische Basis-URL für SEO (Produktion immer hexahost.de)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getCanonicalBaseUrl()
|
||||
{
|
||||
return 'https://' . SITE_DOMAIN_PRODUCTION;
|
||||
}
|
||||
Reference in New Issue
Block a user