diff --git a/src/Http/RequestFactory.php b/src/Http/RequestFactory.php index 15de3deb..4ddfb3e4 100644 --- a/src/Http/RequestFactory.php +++ b/src/Http/RequestFactory.php @@ -265,8 +265,17 @@ public function createHttpRequest(): Request } } } - } + } else { + if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) { + $url->setScheme(strcasecmp($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') === 0 ? 'https' : 'http'); + $url->setPort($url->getScheme() === 'https' ? 443 : 80); + } + if (!empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { + $url->setPort((int) $_SERVER['HTTP_X_FORWARDED_PORT']); + } + } + // method, eg. GET, PUT, ... $method = $_SERVER['REQUEST_METHOD'] ?? null; if (