diff --git a/src/Roots/Acorn/Application/Concerns/Bootable.php b/src/Roots/Acorn/Application/Concerns/Bootable.php index 9b119916..12a6156f 100644 --- a/src/Roots/Acorn/Application/Concerns/Bootable.php +++ b/src/Roots/Acorn/Application/Concerns/Bootable.php @@ -156,6 +156,8 @@ protected function registerDefaultRoute(): void $response->header('X-Powered-By', $this->version()); } + $response->setStatusCode(http_response_code()); + $content = ''; $levels = ob_get_level(); @@ -194,13 +196,6 @@ protected function registerRequestHandler( return; } - if ( - $isApi = Str::startsWith($path, $api) && - redirect_canonical(null, false) - ) { - return; - } - add_filter('do_parse_request', function ($condition, $wp, $params) use ($route) { if (! $route) { return $condition; @@ -215,9 +210,15 @@ protected function registerRequestHandler( return; } - $config = $this->config->get('router.wordpress', ['web' => 'web', 'api' => 'api']); + if (redirect_canonical(null, false)) { + return; + } + + $middleware = Str::startsWith($path, $api) + ? $this->config->get('router.wordpress.api', 'api') + : $this->config->get('router.wordpress.web', 'web'); - $route->middleware($isApi ? $config['api'] : $config['web']); + $route->middleware($middleware); ob_start();