选择您的 Cookie 首选项

我们使用必要 Cookie 和类似工具提供我们的网站和服务。我们使用性能 Cookie 收集匿名统计数据,以便我们可以了解客户如何使用我们的网站并进行改进。必要 Cookie 无法停用,但您可以单击“自定义”或“拒绝”来拒绝性能 Cookie。

如果您同意,AWS 和经批准的第三方还将使用 Cookie 提供有用的网站功能、记住您的首选项并显示相关内容,包括相关广告。要接受或拒绝所有非必要 Cookie,请单击“接受”或“拒绝”。要做出更详细的选择,请单击“自定义”。

向 CloudFront Functions 查看器请求事件添加源标头

聚焦模式
向 CloudFront Functions 查看器请求事件添加源标头 - Amazon CloudFront

以下代码示例演示了如何向 CloudFront Functions 查看器请求事件添加源标头。

JavaScript
适用于 CloudFront Functions 的 JavaScript 运行时 2.0
注意

查看 GitHub,了解更多信息。查找完整示例,并了解如何在 CloudFront Functions examples 存储库中进行设置和运行。

async function handler(event) { var request = event.request; var headers = request.headers; var host = request.headers.host.value; // If origin header is missing, set it equal to the host header. if (!headers.origin) headers.origin = {value:`https://${host}`}; return request; }
适用于 CloudFront Functions 的 JavaScript 运行时 2.0
注意

查看 GitHub,了解更多信息。查找完整示例,并了解如何在 CloudFront Functions examples 存储库中进行设置和运行。

async function handler(event) { var request = event.request; var headers = request.headers; var host = request.headers.host.value; // If origin header is missing, set it equal to the host header. if (!headers.origin) headers.origin = {value:`https://${host}`}; return request; }

有关 AWS SDK 开发人员指南和代码示例的完整列表,请参阅 将 CloudFront 与 AWS SDK 配合使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。

隐私网站条款Cookie 首选项
© 2025, Amazon Web Services, Inc. 或其附属公司。保留所有权利。