{"record":{"id":"cc7af36e5c9729bf","repo":"vercel/next.js","slug":"a-body-was-attempted-to-be-set-with-a-204-statusco","errorCode":null,"errorMessage":"A body was attempted to be set with a 204 statusCode for ${req.url}, this is invalid and the body was ignored.\\nSee more info here https://nextjs.org/docs/messages/invalid-api-status-body","messagePattern":"A body was attempted to be set with a 204 statusCode for (.+?), this is invalid and the body was ignored\\.\\\\nSee more info here https://nextjs\\.org/docs/messages/invalid-api-status-body","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/api-utils/node/api-resolver.ts","lineNumber":71,"sourceCode":" * Send `any` body to response\n * @param req request object\n * @param res response object\n * @param body of response\n */\nfunction sendData(req: NextApiRequest, res: NextApiResponse, body: any): void {\n  if (body === null || body === undefined) {\n    res.end()\n    return\n  }\n\n  // strip irrelevant headers/body\n  if (res.statusCode === 204 || res.statusCode === 304) {\n    res.removeHeader('Content-Type')\n    res.removeHeader('Content-Length')\n    res.removeHeader('Transfer-Encoding')\n\n    if (process.env.NODE_ENV === 'development' && body) {\n      console.warn(\n        `A body was attempted to be set with a 204 statusCode for ${req.url}, this is invalid and the body was ignored.\\n` +\n          `See more info here https://nextjs.org/docs/messages/invalid-api-status-body`\n      )\n    }\n    res.end()\n    return\n  }\n\n  const contentType = res.getHeader('Content-Type')\n\n  if (body instanceof Stream) {\n    if (!contentType) {\n      res.setHeader('Content-Type', 'application/octet-stream')\n    }\n    body.pipe(res)\n    return\n  }\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/server/api-utils/node/api-resolver.ts#L53-L89","documentation":"Error \"A body was attempted to be set with a 204 statusCode for ${req.url}, this is invalid and the body was ignored.\\nSee more info here https://nextjs.org/docs/messages/invalid-api-status-body\" thrown in vercel/next.js.","triggerScenarios":"Thrown at packages/next/src/server/api-utils/node/api-resolver.ts:71 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not send a body with a 204 status code; use `res.status(204).end()` without a payload."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}