From ed5f32fc720e514b09bf7bfc996230a039ff248f Mon Sep 17 00:00:00 2001 From: Tobias Graml Date: Thu, 25 Apr 2024 16:04:05 +0200 Subject: [PATCH] Remove redirect headers from sales channel service --- src/Export/Services/SalesChannelService.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Export/Services/SalesChannelService.php b/src/Export/Services/SalesChannelService.php index 83663472..39b0fb51 100644 --- a/src/Export/Services/SalesChannelService.php +++ b/src/Export/Services/SalesChannelService.php @@ -66,6 +66,15 @@ public function getRequest(Request $originalRequest, SalesChannelContext $salesC $domain = $this->getSalesChannelDomain($salesChannelContext); $parsedUrl = parse_url($domain->getUrl()); + $host = $parsedUrl['host'] . (isset($parsedUrl['port']) ? ':' . $parsedUrl['port'] : ''); + + $serverVariables = array_merge($originalRequest->server->all(), [ + 'REQUEST_URI' => $parsedUrl['path'] ?? '/', + 'SERVER_NAME' => $host, + 'HTTP_HOST' => $host, + ]); + unset($serverVariables['HTTP_FORWARDED']); + unset($serverVariables['HTTP_X_FORWARDED_FOR']); // There is no Request::setUrl(), therefore we need to duplicate the current request object. // @see https://github.com/symfony/symfony/issues/14575#issuecomment-102942494 @@ -75,10 +84,7 @@ public function getRequest(Request $originalRequest, SalesChannelContext $salesC null, null, null, - array_merge($originalRequest->server->all(), [ - 'REQUEST_URI' => $parsedUrl['path'] ?? '/', - 'HTTP_HOST' => $parsedUrl['host'] . (isset($parsedUrl['port']) ? ':' . $parsedUrl['port'] : ''), - ]) + $serverVariables, ); return $this->requestTransformer->transform($request);