Skip to content

Commit

Permalink
feat(TA-1696): set cors allow credentials optionally (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikerudd authored Oct 8, 2024
1 parent d5f3b65 commit 3d32a4a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/authenticated-api/authenticated-api-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface AuthenticatedApiProps {
domainName: string;
certificateArn: string;
corsDomain?: string[];
corsAllowCredentials?: boolean;

// Access logs via CloudWatch log group
logging?: {
Expand Down
2 changes: 1 addition & 1 deletion lib/authenticated-api/authenticated-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class AuthenticatedApi extends Construct {
corsPreflight: {
allowHeaders: ["*"],
allowMethods: [apigatewayv2_alpha.CorsHttpMethod.ANY],
allowCredentials: true,
allowCredentials: props.corsAllowCredentials ?? true,
allowOrigins: props.corsDomain,
},
}),
Expand Down
9 changes: 9 additions & 0 deletions test/infra/authenticated-api/authenticated-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ describe("AuthenticatedApi", () => {
{
Name: "test-MyTestAuthenticatedApi",
ProtocolType: "HTTP",
CorsConfiguration: {
AllowCredentials: true,
AllowHeaders: ["*"],
AllowMethods: ["*"],
AllowOrigins: [
"http://localhost:4200",
`https://test-simple-authenticated-api.talis.com`,
],
},
},
);
});
Expand Down

0 comments on commit 3d32a4a

Please sign in to comment.