This is a small app to be used to showcase how you could use compute to fetch images from "random" source and push them thru Fastly Image Optimizer and store them in cache for a nice user experience.
This code requires you to have a CDN service setup with IO enabled and a Fastly compute service that runs this code.
Deploy the code into fastly using the Fastly CLI. Make sure you have DynamicBackends enabled by Fastly Use a Fastly CDN configured to use the newly deployed compute service as a origin. Request the image thru the CDN
https://<cdn-service-dns>/<domain and image path> (without https:(/))
Example: https://edgeio.boman.church/upload.wikimedia.org/wikipedia/commons/7/70/Example.png
CDN will receive the request, if image is not in cache ask the compute service for the image. Compute service will fetch the image based on the URL/path in the request (assuming HTTPS currently). Compute service will forward the image to CDN that will transform the image using the parameters such as ?width=100&format=webp and serve the user.
- Add security in the way of a header token to validate that this app should run and remove the token from the response.
- Fix the loop issue.
- Stream the file from Compute to origin to avoid running out of heapMemmory at 128mb if it's a really large image
- Remove all response headers from the fetched image in the response to CDN to ensure IO works properly
- Make sure QS's are handled properly from the incomming request to compute to the respones back to CDN where the transformation happens
- Method for handling http and https (will this be required, fallback if HTTPS fails maby)
For more details about other starter kits for Compute, see the Fastly developer hub
Please see our SECURITY.md for guidance on reporting security-related issues.