fix(force_ssl): use scheme instead of server var (#2435)

using some proxy / load balancer may not properly set server https index, thus leading to infinite redirection on force_ssl parameter set to true

align https detection with grav-core code:

a1c116dd82/system/src/Grav/Common/Service/PagesServiceProvider.php (L72-L78)
This commit is contained in:
pips
2025-01-06 15:22:34 +01:00
committed by GitHub
parent d4d02029d0
commit 8dc503c842

View File

@@ -396,9 +396,10 @@ class AdminPlugin extends Plugin
// Force SSL with redirect if required
if ($config->get('system.force_ssl')) {
if (!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) !== 'on') {
$scheme = $this->uri->scheme(true);
if ($scheme !== 'https') {
Admin::DEBUG && Admin::addDebugMessage('Admin SSL forced on, redirect');
$url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$url = 'https://' . $this->uri->host() . $this->uri->uri();
$this->grav->redirect($url);
}
}