Example code for CloudFront Functions
These examples cover different use cases, from caching and security to URL manipulation and token validation. You can use CloudFront Functions to enhance content delivery and customize the behavior of your CloudFront distributions.
Each example function includes brief description and a link to the corresponding code on
GitHub. You can also find these examples in the amazon-cloudfront-functions repository
To help you get started writing function code for CloudFront Functions, see the following examples:
Topics
- Add a Cache-Control header to the response
- Add a cross-origin resource sharing (CORS) header to the response
- Add cross-origin resource sharing (CORS) header to the request
- Add security headers to the response
- Add a True-Client-IP header to the request
- Redirect the viewer to a new URL
- Add index.html to request URLs without a file name
- Validate a simple token in the request
- Use async and await
- Normalize query string parameters
- Use key-value pairs in a function