Skip to content

Commit 912717b

Browse files
committed
fix: defer InjectBoost middleware registration until app is booted
1 parent ee1e448 commit 912717b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/BoostServiceProvider.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,13 @@ private static function mapJsTypeToPsr3Level(string $type): string
180180

181181
private function hookIntoResponses(Router $router): void
182182
{
183-
$router->pushMiddlewareToGroup('web', InjectBoost::class);
183+
// In Kernel-based apps (pre-Laravel 11 bootstrap), middleware groups can be
184+
// defined or overwritten later in the boot cycle, which could remove any
185+
// middleware we push here if we do it too early. Deferring this until the
186+
// application is fully booted ensures our middleware stays appended.
187+
$this->app->booted(function () use ($router) {
188+
$router->pushMiddlewareToGroup('web', InjectBoost::class);
189+
});
184190
}
185191

186192
private function shouldRun(): bool

0 commit comments

Comments
 (0)