in cdk/src/utils.ts [25:58]
static addCorsOptions(apiResource: apigateway.IResource,
origin: string,
allowCredentials: boolean = false,
allowMethods: string = "OPTIONS,GET,PUT,POST,DELETE"
) {
apiResource.addMethod('OPTIONS', new apigateway.MockIntegration({
integrationResponses: [{
statusCode: "200",
responseParameters: {
"method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent'",
"method.response.header.Access-Control-Allow-Origin": "'" + origin + "'",
"method.response.header.Access-Control-Allow-Credentials": "'" + allowCredentials.toString() + "'",
"method.response.header.Access-Control-Allow-Methods": "'" + allowMethods + "'",
"method.response.header.Access-Control-Max-Age": "'7200'",
},
}],
passthroughBehavior: apigateway.PassthroughBehavior.NEVER,
requestTemplates: {
"application/json": "{\"statusCode\": 200}"
},
}), {
methodResponses: [{
statusCode: '200',
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,
"method.response.header.Access-Control-Max-Age": true,
},
}]
})
}