- Update or add the
version
andhandle
methods in yourApp\Http\Middleware\HandleInertiaRequests
middleware. - Add the middleware to the
$routeMiddleware
in yourApp\Http\Kernel
.
Depending on your setup you might not want add the HandleInertiaRequests
middelware directly to the web
middleware stack.
Now you can add the middleware where needed and set the root template with inertia:[view]
.
class RouteServiceProvider extends ServiceProvider
{
public function boot()
{
$this->routes(function () {
Route::middleware('web', 'inertia')
->group(base_path('routes/web.php'));
Route::middleware('web', 'inertia:admin', 'auth')
->group(base_path('routes/admin.php'));
});
}
}
В файл HandleInertiaRequests.php необходимо добавить use Closure; иначе не находит класс Closure