Rückgabeantwort nicht gefundene Laravel -API -Antwort

// 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