withRouting( web: __DIR__.'/../routes/web.php', commands: __DIR__.'/../routes/console.php', health: '/up', ) ->withMiddleware(function (Middleware $middleware): void { $middleware->web(append: [ \App\Http\Middleware\HandleInertiaRequests::class, ]); $middleware->alias([ 'encrypt.history' => \Inertia\Middleware\EncryptHistory::class, ]); }) ->withExceptions(function (Exceptions $exceptions): void { $exceptions->respond(function (\Symfony\Component\HttpFoundation\Response $response, \Throwable $exception, \Illuminate\Http\Request $request) { if (! app()->environment('local') && in_array($response->getStatusCode(), [403, 404, 500, 503])) { return \Inertia\Inertia::render('ErrorPage', ['status' => $response->getStatusCode()]) ->toResponse($request) ->setStatusCode($response->getStatusCode()); } if ($response->getStatusCode() === 419) { return back()->with([ 'message' => 'The page expired, please try again.', ]); } return $response; }); })->create();