Search code examples
laravelvue.jsinertiajslaravel-jetstream

Customize Laravel Jetstream Error Page with inertia


I have a Project Laravel Jetstream with inertia i need change the error page Like This to Vue page enter image description here

I use https://inertiajs.com/error-handling but not work enter image description here

public function render($request, Throwable $e)
{
    $response = parent::render($request, $e);

    if (/*!app()->environment(['local', 'testing']) &&*/in_array($response->status(), [500, 503, 404, 403])) {
        return Inertia::render('Error', ['status' => $response->status()])
            ->toResponse($request)
            ->setStatusCode($response->status());
    } else if ($response->status() === 419) {
        return back()->with([
            'message' => 'The page expired, please try again.',
        ]);
    }

    return $response;
}

Solution

  • This work only in production to work in local

    remove !app()->environment(['local', 'testing']) from the code