diff --git a/bootstrap/app.php b/bootstrap/app.php index 7faf100..eddd995 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -41,5 +41,9 @@ return Application::configure(basePath: dirname(__DIR__)) ]); }) ->withExceptions(function (Exceptions $exceptions): void { - // + // Force JSON responses on /api/* even when client did not send Accept: json. + $exceptions->shouldRenderJsonWhen(function (Request $request, \Throwable $e) { + if ($request->is('api/*')) return true; + return $request->expectsJson(); + }); })->create();