Skip to content

HandleInertiaRequests::share() receives a different request than version() #1517

Closed Answered by benjivm
benjivm asked this question in Help
Discussion options

You must be logged in to vote

This appears to be an issue with global middleware? I created a custom middleware and registered in the 'web' middleware group of the HTTP Kernel and it works now:

ShareInertiaData.php middleware:

class ShareInertiaData
{
    public function handle(Request $request, Closure $next): Response
    {
        Inertia::share([
            'navigation' => [
                ['name' => 'Dashboard', 'href' => route('home'), 'current' => $request->routeIs('home')],
            ],
        ]);

        return $next($request);
    }
}

HTTP Kernel.php:

protected $middlewareGroups = [
    'web' => [
        // ...
        \App\Http\Middleware\ShareInertiaData::class,
    ],

    'api' => [
        // ...

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by benjivm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant