Skip to content

Commit d73aceb

Browse files
committed
Better https detection (patched from develop)
1 parent 1c55d4a commit d73aceb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

common.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
}
116116
}
117117

118-
define('SERVER_URL', 'http' . (isset($_SERVER['HTTPS'][0]) && strtolower($_SERVER['HTTPS']) === 'on' ? 's' : '') . '://' . $baseHost);
118+
define('SERVER_URL', 'http' . (isHttps() ? 's' : '') . '://' . $baseHost);
119119
define('BASE_URL', SERVER_URL . BASE_DIR . '/');
120120
define('ADMIN_URL', SERVER_URL . BASE_DIR . '/admin/');
121121

@@ -125,3 +125,11 @@
125125
}
126126
}
127127
require SYSTEM . 'autoload.php';
128+
129+
function isHttps(): bool
130+
{
131+
return
132+
(!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https')
133+
|| (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
134+
|| (isset($_SERVER['SERVER_PORT']) && (int) $_SERVER['SERVER_PORT'] === 443);
135+
}

0 commit comments

Comments
 (0)