- Newest
- Most votes
- Most comments
It appears you're experiencing an issue with your custom CORS response header policy in CloudFront. When you specify custom origins in the Response Header Policy, CloudFront should add the Access-Control-Allow-Origin header with your specified domain(s) to responses when the request's Origin header matches one of those domains.
There are a few potential reasons why your custom origins configuration isn't working:
-
The Origin header in your curl request might not exactly match one of the origins you've specified in your policy. Make sure the origin value in your request matches exactly what you've configured (including protocol, subdomain, and no trailing slash).
-
You may need to ensure that the OriginOverride setting is properly configured. This setting determines whether CloudFront overrides HTTP response headers received from the origin with the ones specified in your response headers policy.
-
If you recently made these changes, CloudFront might still be propagating the configuration across edge locations. You might need to wait a bit longer or invalidate your cache.
-
Check that the response headers policy is actually attached to the cache behavior in your CloudFront distribution. Creating the policy alone isn't enough - you need to edit your distribution's behavior settings and select the new policy under "Response headers policy".
Since the "All origins" option works correctly (returning access-control-allow-origin: *), the issue is specifically with the custom origins configuration. Try simplifying your test by including just one origin in your custom list to isolate the problem.
If you continue to experience issues, you might want to verify your curl command is correctly sending the Origin header and that the value exactly matches what you've configured in your policy.
Sources
CORS configuration through Amazon CloudFront | Networking & Content Delivery
ResponseHeadersPolicyCorsConfig - Amazon CloudFront
ResponseHeadersPolicyAccessControlAllowOrigins - Amazon CloudFront
COEP and COOP response headers with S3+ Cloudfront | AWS re:Post
Relevant content
- asked 2 years ago

The Origin header was not matching the Origins listed, after matching it, I can see the access-control-allow-origin header in the response