in app/lib/medical-transcription-analysis-stack.ts [397:442]
function addCorsOptionsAndMethods(apiResource: apigateway.IResource | apigateway.Resource, methods: string[] | []) {
const options = 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': "'*'",
'method.response.header.Access-Control-Allow-Credentials': "'false'",
'method.response.header.Access-Control-Allow-Methods': "'OPTIONS,GET,PUT,POST,DELETE'",
},
},
],
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,
},
},
],
requestValidator: reqValidator,
},
);
methods.forEach((method) => {
apiResource.addMethod(method, undefined, {
authorizationType: apigateway.AuthorizationType.COGNITO,
authorizer: {
authorizerId: `${authorizer.ref}`,
},
});
});
}