如何在云端自定义源请求策略中将授权 header 列入白名单

How to Whitelist Authorization header in cloudfront custom origin request policy

从 serverfault

交叉 post

https://serverfault.com/questions/1053906/how-to-whitelist-authorization-header-in-cloudfront-custom-origin-request-policy

有问题的 post,我也 运行 并正在寻求答案。我必须使用 AWS-CDK 和 cloudformation,因此使用非遗留解决方案是理想的

我试图制定一个新的源请求策略,该策略将通过所有查看器 headers,我在我的请求 header(授权)中看到了它,但得到了 cors No 'Access-Control-Allow-Origin' header is present on the requested resource.

看来您有 3 种方式转发授权 header:

1- 在 header 选项下创建来源请求策略和 select“所有查看者 headers”。

您不能在原始请求策略中单独转发授权 header,但是当您转发所有查看器时 header,CloudFront 在查看器请求中包含授权 header

2- 使用缓存策略将授权 header 添加到缓存键。缓存键中的所有 header 都自动包含在源请求中

3- 使用旧缓存设置

不幸的是,没有其他办法。