json([ 'message' => 'SUPERADMIN_REMOTE_TOKEN is not configured', ], 503); } $auth = (string) $request->header('Authorization', ''); $token = ''; if (preg_match('/^\s*Bearer\s+(.+)\s*$/i', $auth, $m)) { $token = trim($m[1]); } if ($token === '' || ! hash_equals($expected, $token)) { return response()->json(['message' => 'Unauthorized'], 401); } return $next($request); } }