CloudFront 已被 CORS 策略阻止

CloudFront has been blocked by CORS policy

我使用 axios 从我的 cdn(由 aws CloudFront 提供服务)获取资源(md 文件)。

我在浏览器中收到此错误消息:

Access to XMLHttpRequest at 'https://next.cdn.example.com/foo/bar.md' from origin 'https://next.example.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource

My website is: https://next.example.com
My cdn: https://next.cdn.example.com

但在 CloudFront 中,我设置了一切以支持 CORS(在图片中)。

我还能做些什么来解决这个问题?

S3

CloudFront

我相信您还需要在 CloudFront 的行为设置上允许 OPTIONS 请求。 OPTIONS 请求在 CORS 请求的实际 GET/POST 请求之前发送,有关详细信息,请参阅 https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Functional_overview