@devhoussam123 Have you found a solution to your error?
Sep 23, 2023
8
Level 2
How to customize Laravel 10 with Inertia.js v1.0 Error Pages?
I follow the https://inertiajs.com/error-handling but i still can't get my js/Pages/Errors/404.vue Page when I type a not found url example: https://laravel-inertia.test/foo
composer.json
"inertiajs/inertia-laravel": "^0.6.8",
"laravel/framework": "^10.10",
package.json
"vue": "^3.2.31"
Handler.php
<?php
namespace App\Exceptions;
use Throwable;
use Inertia\Inertia;
use Illuminate\Http\Request;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* The list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*/
public function register(): void
{
$this->renderable(function (Throwable $e, Request $request) {
$response = parent::render($request, $e);
$status = $response->status();
if (! app()->environment(['local', 'testing'])) {
return match ($status) {
404 => Inertia::render('Errors/404')->toResponse($request)->setStatusCode($status),
default => $response
};
}
return $response;
});
}
}
js/Pages/Errors/404.vue
<script setup>
import GuestLayout from "@/Layouts/GuestLayout.vue";
</script>
<template>
<GuestLayout title="404">
<div class="py-5">
<div class="container py-5">
<h1 class="display-4 fw-bold">
Error 404 Not Found
</h1>
</div>
</div>
</GuestLayout>
</template>
.env
APP_ENV=production
Please or to participate in this conversation.