

# x-amazon-apigateway-cors 对象
<a name="api-gateway-swagger-extensions-cors-configuration"></a>

为 HTTP API 指定跨域资源共享 (CORS) 配置。扩展适用于根级 OpenAPI 结构。要了解更多信息，请参阅“[为 API Gateway 中的 HTTP API 配置 CORS](http-api-cors.md)”。


| 属性名称 | 类型 | 说明 | 
| --- | --- | --- | 
| allowOrigins | Array |  指定允许的源。  | 
| allowCredentials | Boolean |  指定是否在 CORS 请求中包含凭证。  | 
| exposeHeaders | Array |  指定公开的标头。  | 
| maxAge | Integer |  指定浏览器应缓存预检请求结果的秒数。  | 
| allowMethods | Array |  指定允许的 HTTP 方法。  | 
| allowHeaders | Array |  指定允许的标头。  | 

## x-amazon-apigateway-cors 示例
<a name="api-gateway-swagger-extensions-cors-configuration"></a>

以下是用于 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"
    ]
}
```