为API Gateway和S3资源添加CORS配置,以允许来自特定源的跨域请求。以下是针对API Gateway和S3资源的解决方法示例:
API Gateway CORS配置:
S3 CORS配置:
以下是API Gateway和S3的CORS配置示例代码: API Gateway:
{
"swagger": "2.0",
"info": {
"title": "YOUR_API_TITLE",
"version": "1.0"
},
"schemes":[
"https"
],
"securityDefinitions": {},
"paths": {
"/your-resource": {
"options": {
"summary": "CORS support",
"description": "Enable CORS by returning correct headers",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"CORS"
],
"responses": {
"200": {
"description": "Default response for CORS method",
"headers": {
"Access-Control-Allow-Headers": {
"type": "string"
},
"Access-Control-Allow-Methods": {
"type": "string"
},
"Access-Control-Allow-Origin": {
"type": "string"
}
}
}
}
}
}
},
"definitions": {}
}
S3:
*
GET
POST
3000
Authorization