Odpowiedź powrotna Nie znaleziono odpowiedzi API Laravel

// In Laravel 9
// Update register() in App/Exceptions/Handler.php
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

public function register()
{
    $this->renderable(function (NotFoundHttpException $e, $request) {
        if ($request->is('api/*')) {
            return response()->json([
                'message' => 'Not found.'
            ], 404);
        }
    });
}
Snippets