diff --git a/app/Containers/Dashboard/UI/WEB/Middleware/EnsureDashboardAuthenticated.php b/app/Containers/Dashboard/UI/WEB/Middleware/EnsureDashboardAuthenticated.php index 5e9db34..0017253 100644 --- a/app/Containers/Dashboard/UI/WEB/Middleware/EnsureDashboardAuthenticated.php +++ b/app/Containers/Dashboard/UI/WEB/Middleware/EnsureDashboardAuthenticated.php @@ -15,6 +15,9 @@ class EnsureDashboardAuthenticated public function handle(Request $request, Closure $next): Response { if (!Auth::check()) { + if ($request->expectsJson() || $request->is('api/*')) { + return response()->json(['error' => 'Unauthenticated'], 401); + } return redirect()->route('login'); }