Skip to content

Commit

Permalink
🔧 Add back API middleware config
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x committed Nov 6, 2024
1 parent 746833a commit 21d6df5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Roots/Acorn/Application/Concerns/Bootable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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);

Expand Down

0 comments on commit 21d6df5

Please sign in to comment.