You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 28, 2025. It is now read-only.
When returning a status code of 204 in the response of a next api route, AWS lambda at edge raises an validation error Response Contains a Body and Specifies 204 (No Content) for Status due to the presence of the body property in the response object.
Describe the bug
When returning a status code of 204 in the response of a next api route, AWS lambda at edge raises an validation error
Response Contains a Body and Specifies 204 (No Content) for Status
due to the presence of the body property in the response object.To Reproduce
Take an example next api handler
The res object with be transformed into a lambda at edge response object by
However this does not take into account the need to omit the body object with a 204 response as detailed here under errors:
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-generating-http-responses-in-requests.html
So for a 204 status response, a body property with an empty value is included and the cloudfront validation fails.
Expected behavior
If an API handler returns a status of 204, the cloudfront response object should omit the body property.
The text was updated successfully, but these errors were encountered: