withRouting( web: __DIR__.'/../routes/web.php', api: __DIR__.'/../routes/api.php', commands: __DIR__.'/../routes/console.php', health: '/up', ) ->withMiddleware(function (Middleware $middleware): void { // SAML-Antworten kommen per POST vom Anbieter (siehe routes/web.php). $middleware->validateCsrfTokens(except: ['auth/*/callback']); $middleware->web(prepend: [ EnsureNotInMaintenance::class, RedirectToInstaller::class, ], append: [ RunPendingMigrations::class, ThemePreview::class, HandleInertiaRequests::class, RunPseudoCron::class, ]); }) ->withExceptions(function (Exceptions $exceptions): void { // Im Fehlerprotokoll steht, welche Adresse und welche Person betroffen war (Systemzustand → Letzte Fehler) $exceptions->context(fn () => app()->runningInConsole() ? [] : array_filter([ 'url' => request()->method().' '.request()->fullUrl(), 'user_id' => auth()->id(), ])); $exceptions->shouldRenderJsonWhen( fn (Request $request) => $request->is('api/*') || $request->expectsJson(), ); })->create();