diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 97e5674bd9bf..d3c548d03606 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -339,6 +339,20 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon $this->getRequestObject(); $this->getResponseObject(); + try { + $this->forceSecureAccess(); + } catch (RedirectException $e) { + $this->response = $e->getResponse(); + + if ($returnResponse) { + return $this->response; + } + + $this->sendResponse(); + + return; + } + Events::trigger('pre_system'); $this->benchmark->stop('bootstrap'); @@ -354,8 +368,6 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon $this->response = $possibleResponse; } else { try { - $this->forceSecureAccess(); - $this->response = $this->handleRequest($routes, config(Cache::class), $returnResponse); } catch (ResponsableInterface|DeprecatedRedirectException $e) { $this->outputBufferingEnd();