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

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南