2 réponses
- Le plus récent
- Le plus de votes
- La plupart des commentaires
0
I do not believe it is feasible to modify the body of HTTP response in Lambda@Edge response triggers. See the documentation below:
When you’re working with the HTTP response, Lambda@Edge does not expose the HTML body that is returned by the origin server to the origin-response trigger.
répondu il y a 4 ans
0
I just want to provide an updated answer to this question. Using a Lambda@Edge origin response function, you can fetch the current html file from S3 and load it into a variable. From there you can modify the payload and then reset it as a new payload. Here is a simple example of fetching the file from S3, but you would still need to write something to modify the payload.
https.get(`https://bucketname.s3.amazonaws.com/index.html`, (res) => {
res.on('data', (d) => {
let file = decoder.write(Buffer.from(d, 'base64'));
response.status = '200';
response.statusDescription = "OK";
response.body = file;
return response;
});
}).on('error', (e) => {
console.error(e);
});
répondu il y a 2 ans
Contenus pertinents
- demandé il y a un an
- demandé il y a 3 mois
- demandé il y a un an
- AWS OFFICIELA mis à jour il y a 2 ans
- Comment résoudre les erreurs 500, 502 et 503 causées par les fonctions Lambda@Edge dans CloudFront ?AWS OFFICIELA mis à jour il y a 2 ans
- AWS OFFICIELA mis à jour il y a 2 ans
- AWS OFFICIELA mis à jour il y a 6 mois