CORS for AWS CloudFront: Practical Setup and Gotchas

CORS on CloudFront looks simple until caching gets involved. That’s the part that bites people. You add Access-Control-Allow-Origin, test once, it works, then a different origin starts failing or getting the wrong response from cache. If you’ve ever had a “works in curl, fails in browser” day with CloudFront, this is usually why. I’m going to show the setups that actually work in production: static assets behind CloudFront APIs behind CloudFront S3 origins custom origins like ALB, EC2, or API backends dynamic origin allowlists preflight caching without poisoning your edge cache What CloudFront does in a CORS flow CloudFront is a cache and proxy sitting between the browser and your origin. ...

October 14, 2026 · 7 min · headertest.com