Dynamic data to Cloudfront error pages

0

I have a cloudfront distribution setup to serve images from an s3 bucket, and a custom error page to handle 404 responses if the image does not exist in my bucket. The error page points to an API Gateway endpoint that generates an image given a set of parameters. Those parameters are provided by the client through the input URI when making a request to the cloudfront distribution.

Is there a way for me to pass that data to my API endpoint, like adding headers or query parameters to the url? The problem I am facing is that when the original client request is met with a 404 response, the error page handler makes a separate request to the desired endpoint (which is a static url), and does not seem to carry over any data from the original request.

jack
已提问 1 个月前225 查看次数
1 回答
0

Hello, try to pass the required parameters to your API Gateway endpoint by appending them as query parameters to the error page URL. This way, when the error page handler triggers a request to the API endpoint, the parameters will be included in the URL and accessible to your endpoint for generating the image.

profile picture
专家
已回答 1 个月前
  • How can I append dynamic parameters to the error page url? A client might request asset 1 with a set of modifications which might 404, requiring an api call. Another client might request asset 2 with another set of modifications which might also 404, requiring another API call with specific query parameters for that request

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则

相关内容