fix: portalUrl stays on proxy host when accessed via reverse proxy on port 443

When HTTP_HOST has no port (NPM on 443), return URL without appending panel port.
Direct access (HTTP_HOST includes :8882 etc.) still redirects to correct port.
Prevents browser being sent to :8882 directly after login via novacpx.orbishosting.com.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LP9Q4kfCAYAjJnsbHBrViZ
This commit is contained in:
2026-06-20 05:27:30 +00:00
parent ab7c69d086
commit 91bf8d965f
+5
View File
@@ -151,6 +151,11 @@ class Auth {
*/ */
public static function portalUrl(string $role, string $path = '/'): string { public static function portalUrl(string $role, string $path = '/'): string {
$host = $_SERVER['HTTP_HOST'] ?? 'localhost'; $host = $_SERVER['HTTP_HOST'] ?? 'localhost';
// No port in HTTP_HOST means the request came through a reverse proxy on 443 — stay on same host
if (!preg_match('/:\d+$/', $host)) {
return "https://{$host}{$path}";
}
// Direct access — redirect to the correct panel port
$hostname = preg_replace('/:\d+$/', '', $host); $hostname = preg_replace('/:\d+$/', '', $host);
$port = match($role) { $port = match($role) {
'admin' => PORT_ADMIN, 'admin' => PORT_ADMIN,