1 Answer
- Newest
- Most votes
- Most comments
0
You cannot use Viewer request to detect 4XX and above errors, because those are responses and at the time of Viewer request there is no response. Also you can't use Viewer Response for the 4XX and above errors as that is not supported on Functions.
If the origin returns an HTTP error of 400 and above, the CloudFront Function will not run.
Source: Status code and body
You can instead use the default custom error page to return your data instead. Find out more under Generating custom error responses -documentation.
Relevant content
- asked 7 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago