Skip to content

Commit feffd6d

Browse files
committed
Add CORS configuration to API Gateway and backend
1 parent 30f93bc commit feffd6d

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

backend/src/iac/backend-stack.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -466,16 +466,22 @@ export class BackendStack extends cdk.Stack {
466466
apigateway.ResponseType.INTEGRATION_TIMEOUT,
467467
];
468468

469-
gatewayResponseTypes.forEach((responseType) => {
470-
new apigateway.CfnGatewayResponse(this, `${appName}GatewayResponse${responseType}-${props.environment}`, {
471-
restApiId: api.restApiId,
472-
responseType: responseType.toString(),
473-
responseParameters: {
474-
'gatewayresponse.header.Access-Control-Allow-Origin': "'*'",
475-
'gatewayresponse.header.Access-Control-Allow-Headers': "'Content-Type,Authorization,X-Amz-Date,X-Api-Key'",
476-
'gatewayresponse.header.Access-Control-Allow-Methods': "'GET,POST,PUT,PATCH,DELETE,OPTIONS'"
469+
gatewayResponseTypes.forEach(responseType => {
470+
new apigateway.CfnGatewayResponse(
471+
this,
472+
`${appName}GatewayResponse${responseType}-${props.environment}`,
473+
{
474+
restApiId: api.restApiId,
475+
responseType: responseType.toString(),
476+
responseParameters: {
477+
'gatewayresponse.header.Access-Control-Allow-Origin': "'*'",
478+
'gatewayresponse.header.Access-Control-Allow-Headers':
479+
"'Content-Type,Authorization,X-Amz-Date,X-Api-Key'",
480+
'gatewayresponse.header.Access-Control-Allow-Methods':
481+
"'GET,POST,PUT,PATCH,DELETE,OPTIONS'",
482+
},
477483
},
478-
});
484+
);
479485
});
480486

481487
// Create API Gateway execution role with required permissions

0 commit comments

Comments
 (0)