Fix: Usar APP_URL del .env para redirección al login

This commit is contained in:
2026-02-19 14:25:56 -06:00
parent b002982faa
commit e2644749cc

View File

@@ -24,8 +24,10 @@ function checkSession(): void
validateSessionDomain();
if (!isset($_SESSION['user_id'])) {
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
$appUrl = $_ENV['APP_URL'] ?? getenv('APP_URL') ?? '';
$parsed = parse_url($appUrl);
$scheme = $parsed['scheme'] ?? 'https';
$host = $parsed['host'] ?? $_SERVER['HTTP_HOST'] ?? 'localhost';
header('Location: ' . $scheme . '://' . $host . '/login.php');
exit;
}