x-amazon-apigateway-cors 对象 - Amazon API Gateway
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

x-amazon-apigateway-cors 对象

为 HTTP API 指定跨域资源共享 (CORS) 配置。扩展适用于根级 OpenAPI 结构。要了解更多信息,请参阅“为 HTTP API 配置 CORS”。

属性
属性名称 类型 说明
allowOrigins Array

指定允许的源。

allowCredentials Boolean

指定是否在 CORS 请求中包含凭证。

exposeHeaders Array

指定公开的标头。

maxAge Integer

指定浏览器应缓存预检请求结果的秒数。

allowMethods Array

指定允许的 HTTP 方法。

allowHeaders Array

指定允许的标头。

x-amazon-apigateway-cors 示例

以下是用于 HTTP API 的 CORS 配置示例。

"x-amazon-apigateway-cors": { "allowOrigins": [ "https://www.example.com" ], "allowCredentials": true, "exposeHeaders": [ "x-apigateway-header", "x-amz-date", "content-type" ], "maxAge": 3600, "allowMethods": [ "GET", "OPTIONS", "POST" ], "allowHeaders": [ "x-apigateway-header", "x-amz-date", "content-type" ] }