aws-samples / aws-samples/amazon-cloudfront-functions

Response interceptor

Open
#33 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
533
Forks
76
PR merge metrics
No merged PRs in 30d

Description

Can you please consider adding a feature to intercept the response HTML? Something like this:

```
function handler(event) {
var request = event.request;
var response = event.response;

// meta tags array
// Even better if we can fetch tags from DynamoDB in future?
const tags = [
{ name: “example1.domain.com”, value : “abc”},
{ name: “example2.domain.com”, value : “cuz”}
]

// find meta tags for custom domain
const meta = tags.find(x => x.name == request.host)

// Inject in index.html received from S3
response.content.replace(“<\head>”, ‘<\head>’

return response;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.