diff --git a/src/Roots/Acorn/Application/Concerns/Bootable.php b/src/Roots/Acorn/Application/Concerns/Bootable.php index 9b119916..9575c85e 100644 --- a/src/Roots/Acorn/Application/Concerns/Bootable.php +++ b/src/Roots/Acorn/Application/Concerns/Bootable.php @@ -180,13 +180,12 @@ protected function registerRequestHandler( $path = Str::finish($request->getBaseUrl(), $request->getPathInfo()); $except = collect([ + rest_url(), admin_url(), wp_login_url(), wp_registration_url(), ])->map(fn ($url) => parse_url($url, PHP_URL_PATH))->unique()->filter(); - $api = parse_url(rest_url(), PHP_URL_PATH); - if ( Str::startsWith($path, $except->all()) || Str::endsWith($path, '.php') @@ -194,13 +193,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 +207,11 @@ protected function registerRequestHandler( return; } - $config = $this->config->get('router.wordpress', ['web' => 'web', 'api' => 'api']); + if (redirect_canonical(null, false)) { + return; + } - $route->middleware($isApi ? $config['api'] : $config['web']); + $route->middleware('web'); ob_start();