【发布时间】:2021-01-08 04:25:48
【问题描述】:
我在使用 cloudfront(签名 cookie)提供私人文件时遇到问题。
从邮递员那里它可以工作,但如果我尝试从 HTML 显示图像(我在显示之前设置了 cookie)会发生以下情况:
-
如果我将 crossOrigin = "use-credentials" 添加到图像标签,则出现 CORS 错误“已被 CORS 策略阻止:请求的资源上不存在 'Access-Control-Allow-Origin' 标头。”
-
如果我不添加交叉原点,则会出现 403 错误。
S3 配置为:
<? xml version = "1.0" encoding = "UTF-8"?>
<CORSConfiguration xmlns = "http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
【问题讨论】:
标签: amazon-web-services amazon-s3 cors amazon-cloudfront