rsnext/test/integration/api-support/pages/api/status-204.js
JJ Kasper ead10f1f81
Fix handling for 204 status code with a body (#28479)
This ensures we handle 204 and 304 status codes correctly in API routes.  

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`

Fixes: https://github.com/vercel/next.js/issues/28464
2021-08-25 15:52:43 +00:00

7 lines
226 B
JavaScript

export default function handler(req, res) {
if (req.query.invalid) {
// test the warning when content is added for a 204 response
return res.status(204).json({ hello: 'world' })
}
return res.status(204).send()
}