Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion boot/Editor/Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,13 @@ private static function editorSegments(array $config): UrlSegments

private static function detectSiteUrl(): string
{
$scheme = (! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
// Prefer X-Forwarded-Proto when present — TLS-terminating reverse
// proxies (nginx-proxy, traefik, …) reach PHP over plain HTTP
// and signal the original scheme via this header. First value
// wins for chained proxies ("https,http").
$proto = $_SERVER['HTTP_X_FORWARDED_PROTO']
?? ((! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http');
$scheme = strtolower(trim(explode(',', $proto)[0])) === 'https' ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
return $scheme . '://' . $host;
}
Expand Down
8 changes: 7 additions & 1 deletion boot/Frontend/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,13 @@ protected function renderNavigation(): string

private static function detectSiteUrl(): string
{
$scheme = (! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
// Prefer X-Forwarded-Proto when present — TLS-terminating reverse
// proxies (nginx-proxy, traefik, …) reach PHP over plain HTTP
// and signal the original scheme via this header. First value
// wins for chained proxies ("https,http").
$proto = $_SERVER['HTTP_X_FORWARDED_PROTO']
?? ((! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http');
$scheme = strtolower(trim(explode(',', $proto)[0])) === 'https' ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
return $scheme . '://' . $host;
}
Expand Down