Description
Laravel Version
12.x
PHP Version
8.2
Database Driver & Version
Sqllite / Any
Description
When installing Laravel Breeze (Vue/Inertia stack) or Jetstream (Inertia stack) into a fresh project created with composer create-project
, the installation command does not add the required HandleInertiaRequests
middleware to the web
group in bootstrap/app.php
. This prevents Inertia from functioning correctly.
Steps To Reproduce
-
Create a fresh Laravel project using Composer:
composer create-project laravel/laravel Your-App-Name
-
Require either the Breeze or Jetstream package:
For Breeze:
composer require laravel/breeze --dev
For Jetstream:
composer require laravel/jetstream
- Run the corresponding install command for an Inertia stack:
For Breeze:
php artisan breeze:install vue
For Jetstream:
php artisan jetstream:install inertia
- Observe the contents of the bootstrap/app.php file.
Observed Behavior (The Bug)
After running the installation, the bootstrap/app.php file remains unchanged and is missing the Inertia middleware. The withMiddleware section looks like this:
->withMiddleware(function (Middleware $middleware): void {
//
})
Expected Behavior (The Fix)
The breeze:install or jetstream:install command should automatically modify bootstrap/app.php to append the necessary middleware for Inertia to work. The withMiddleware section should look like this:
->withMiddleware(function (Middleware $middleware): void {
$middleware->web(append: [
\App\Http\Middleware\HandleInertiaRequests::class,
\Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class,
]);
})