From 1df7361d7e4561b93e8666193c44102ffea21bc9 Mon Sep 17 00:00:00 2001 From: Vasyka Date: Thu, 7 May 2026 19:36:46 +0000 Subject: [PATCH] fix: force JSON responses on /api/* routes --- bootstrap/app.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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();