serverless-binary-cors
serverless-binary-cors copied to clipboard
Different solution
Hi, so I just thought I mention that there is a ContentHandling param on the Integration of the method, setting this does the job ("ContentHandling": "CONVERT_TO_TEXT",), no need for that wacky hack
It is a variable NOT available through the AWS Console, only CF and cli.
"digitaldiplomaapirestv1featurecorsfixeventsOPTIONSABE7A0A7": {
"Type": "AWS::ApiGateway::Method",
"Properties": {
"HttpMethod": "OPTIONS",
"ResourceId": {
"Ref": "digitaldiplomaapirestv1featurecorsfixeventsAB696234"
},
"RestApiId": {
"Ref": "digitaldiplomaapirestv1featurecorsfixBD6C2ED5"
},
"AuthorizationType": "NONE",
"Integration": {
"ContentHandling": "CONVERT_TO_TEXT",
"IntegrationResponses": [
{
"ResponseParameters": {
"method.response.header.Access-Control-Allow-Headers": "'*'",
"method.response.header.Access-Control-Allow-Origin": "'*'",
"method.response.header.Access-Control-Allow-Credentials": "'true'",
"method.response.header.Access-Control-Allow-Methods": "'OPTIONS,GET,PUT,POST,DELETE,PATCH,HEAD'"
},
"StatusCode": "204"
}
],
"RequestTemplates": {
"application/json": "{ \"statusCode\": 204 }"
},
"Type": "MOCK"
},
"MethodResponses": [
{
"ResponseParameters": {
"method.response.header.Access-Control-Allow-Headers": true,
"method.response.header.Access-Control-Allow-Methods": true,
"method.response.header.Access-Control-Allow-Credentials": true,
"method.response.header.Access-Control-Allow-Origin": true
},
"StatusCode": "204"
}
]
},
"Metadata": {
"aws:cdk:path": "digital-diploma-api-v1-feature-cors-fix/digital-diploma-api-rest-v1-feature-cors-fix/Default/events/OPTIONS/Resource"
}
},
In 2024 this is now available in the console.