--- a/classes/shop/ShopUrl.php +++ b/classes/shop/ShopUrl.php @@ -175,15 +175,23 @@ public static function getMainShopDomain($id_shop = null) { - ShopUrl::cacheMainDomainForShop($id_shop); - - return self::$main_domain[(int) $id_shop] ?? null; + // EduBox: dynamic public domain behind reverse proxy or direct local access. + // Always use the request host instead of the domain stored in database. + // Keep non-standard ports (e.g. localhost:8088) so local access works. + $host = Tools::getHttpHost(false, false, false); + if (substr($host, -3) === ':80' || substr($host, -4) === ':443') { + $host = substr($host, 0, strrpos($host, ':')); + } + return $host; } public static function getMainShopDomainSSL($id_shop = null) { - ShopUrl::cacheMainDomainForShop($id_shop); - - return self::$main_domain_ssl[(int) $id_shop] ?? null; + // EduBox: dynamic public domain behind reverse proxy or direct local access. + $host = Tools::getHttpHost(false, false, false); + if (substr($host, -3) === ':80' || substr($host, -4) === ':443') { + $host = substr($host, 0, strrpos($host, ':')); + } + return $host; } }