diff --git a/src/Roots/Acorn/Application/Concerns/Bootable.php b/src/Roots/Acorn/Application/Concerns/Bootable.php index 02827e25..c676bf0c 100644 --- a/src/Roots/Acorn/Application/Concerns/Bootable.php +++ b/src/Roots/Acorn/Application/Concerns/Bootable.php @@ -180,12 +180,13 @@ 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') @@ -211,7 +212,9 @@ protected function registerRequestHandler( return; } - $middleware = $this->config->get('router.wordpress.web', 'web'); + $middleware = Str::startsWith($path, $api) + ? $this->config->get('router.wordpress.api', 'api') + : $this->config->get('router.wordpress.web', 'web'); $route->middleware($middleware);