diff --git a/src/BitWeb/ErrorReporting/Service/ErrorService.php b/src/BitWeb/ErrorReporting/Service/ErrorService.php index b74291f..1e29402 100644 --- a/src/BitWeb/ErrorReporting/Service/ErrorService.php +++ b/src/BitWeb/ErrorReporting/Service/ErrorService.php @@ -253,7 +253,7 @@ public function getUrl() { if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) { $prefix = (array_key_exists('HTTP_X_FORWARDED_PROTO', $_SERVER) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') ? 'https://' : 'http://'; - $domain = $_SERVER['HTTP_X_FORWARDED_FOR']; + $domain = $_SERVER['HTTP_HOST']; } else { $prefix = (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] === 'on') ? 'https://' : 'http://'; $domain = $_SERVER['SERVER_NAME']; diff --git a/test/BitWebTest/ErrorReporting/Service/ErrorServiceTest.php b/test/BitWebTest/ErrorReporting/Service/ErrorServiceTest.php index cc937e9..ede19a1 100644 --- a/test/BitWebTest/ErrorReporting/Service/ErrorServiceTest.php +++ b/test/BitWebTest/ErrorReporting/Service/ErrorServiceTest.php @@ -213,7 +213,8 @@ public function testGetUrlWithHttp() public function testGetUrlWithXForwardedFor() { - $_SERVER['HTTP_X_FORWARDED_FOR'] = 'bitweb.ee'; + $_SERVER['HTTP_HOST'] = 'bitweb.ee'; + $_SERVER['HTTP_X_FORWARDED_FOR'] = '127.0.0.1'; $_SERVER['SERVER_NAME'] = 'localhost'; $_SERVER['REQUEST_URI'] = '/error-reporting';