【问题标题】:Why do I have CORS client side errors using AWS CloudFront?为什么使用 AWS CloudFront 时出现 CORS 客户端错误?
【发布时间】:2021-01-08 04:25:48
【问题描述】:

我在使用 cloudfront(签名 cookie)提供私人文件时遇到问题。

从邮递员那里它可以工作,但如果我尝试从 HTML 显示图像(我在显示之前设置了 cookie)会发生以下情况:

  1. 如果我将 crossOrigin = "use-credentials" 添加到图像标签,则出现 CORS 错误“已被 CORS 策略阻止:请求的资源上不存在 'Access-Control-Allow-Origin' 标头。”

  2. 如果我不添加交叉原点,则会出现 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>

我在云端分发中只有 1 个行为,这就是我所拥有的:

最后这就是我生成 cookie 的方式(服务器端)

【问题讨论】:

    标签: amazon-web-services amazon-s3 cors amazon-cloudfront


    【解决方案1】:

    尝试激活“允许的 HTTP 方法”以激活 GET, HEAD, OPTIONS instad only GET, HEAD

    【讨论】:

      猜你喜欢
      • 2021-06-13
      • 1970-01-01
      • 2020-06-03
      • 1970-01-01
      • 2023-01-13
      • 2020-06-17
      • 2021-02-24
      • 2021-11-10
      • 1970-01-01
      相关资源
      最近更新 更多