From 21d6df5598aef36ece37b8194347dcb497272152 Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 6 Nov 2024 15:22:02 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Add=20back=20API=20middleware=20?= =?UTF-8?q?config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Application/Concerns/Bootable.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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);