本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
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" ] }