method(), ['POST', 'PUT', 'PATCH'])) { $contentType = $request->header('Content-Type', ''); if (! str_contains($contentType, 'application/json')) { return response()->json([ 'error' => 'Content-Type must be application/json.', ], 415); } if (strlen($request->getContent()) > self::MAX_BODY_SIZE) { return response()->json([ 'error' => 'Request body too large. Maximum 64KB.', ], 413); } } return $next($request); } }