Skip to content

[Breeze/Jetstream] Inertia middleware not added to bootstrap/app.php #56053

Closed
laravel/breeze
#473
@mdtaufiquekhan

Description

@mdtaufiquekhan

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

  1. Create a fresh Laravel project using Composer:
    composer create-project laravel/laravel Your-App-Name

  2. Require either the Breeze or Jetstream package:

For Breeze:
composer require laravel/breeze --dev

For Jetstream:
composer require laravel/jetstream

  1. Run the corresponding install command for an Inertia stack:

For Breeze:
php artisan breeze:install vue

For Jetstream:
php artisan jetstream:install inertia

  1. 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,
    ]);
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions