Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where wrong origin set on API CORS policy #261

Merged
merged 2 commits into from
Apr 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions cloudformation/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Resources:
method.response.header.Access-Control-Allow-Headers: "'Content-Type,Authorization,X-Amz-Date,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Origin: !If [ 'DevelopmentMode', "'*'", !If [
'UseCustomDomainName',
!Join ['', [ "'https://", !GetAtt CustomDomainCloudfrontDistribution.DomainName, "'" ]],
!Join ['', [ "'https://", !Ref CustomDomainName, "'" ]],
!Join ['', [ "'https://", !GetAtt DefaultCloudfrontDistribution.DomainName, "'" ]]
]]
passthroughBehavior: when_no_match
Expand Down Expand Up @@ -231,7 +231,7 @@ Resources:
method.response.header.Access-Control-Allow-Headers: "'Content-Type,Authorization,X-Amz-Date,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Origin: !If [ 'DevelopmentMode', "'*'", !If [
'UseCustomDomainName',
!Join ['', [ "'https://", !GetAtt CustomDomainCloudfrontDistribution.DomainName, "'" ]],
!Join ['', [ "'https://", !Ref CustomDomainName, "'" ]],
!Join ['', [ "'https://", !GetAtt DefaultCloudfrontDistribution.DomainName, "'" ]]
]]
passthroughBehavior: when_no_match
Expand Down Expand Up @@ -278,7 +278,7 @@ Resources:
method.response.header.Access-Control-Allow-Headers: "'Content-Type,Authorization,X-Amz-Date,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Origin: !If [ 'DevelopmentMode', "'*'", !If [
'UseCustomDomainName',
!Join ['', [ "'https://", !GetAtt CustomDomainCloudfrontDistribution.DomainName, "'" ]],
!Join ['', [ "'https://", !Ref CustomDomainName, "'" ]],
!Join ['', [ "'https://", !GetAtt DefaultCloudfrontDistribution.DomainName, "'" ]]
]]
passthroughBehavior: when_no_match
Expand Down Expand Up @@ -325,7 +325,7 @@ Resources:
method.response.header.Access-Control-Allow-Headers: "'Content-Type,Authorization,X-Amz-Date,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Origin: !If [ 'DevelopmentMode', "'*'", !If [
'UseCustomDomainName',
!Join ['', [ "'https://", !GetAtt CustomDomainCloudfrontDistribution.DomainName, "'" ]],
!Join ['', [ "'https://", !Ref CustomDomainName, "'" ]],
!Join ['', [ "'https://", !GetAtt DefaultCloudfrontDistribution.DomainName, "'" ]]
]]
passthroughBehavior: when_no_match
Expand Down Expand Up @@ -398,7 +398,7 @@ Resources:
method.response.header.Access-Control-Allow-Headers: "'Content-Type,Authorization,X-Amz-Date,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Origin: !If [ 'DevelopmentMode', "'*'", !If [
'UseCustomDomainName',
!Join ['', [ "'https://", !GetAtt CustomDomainCloudfrontDistribution.DomainName, "'" ]],
!Join ['', [ "'https://", !Ref CustomDomainName, "'" ]],
!Join ['', [ "'https://", !GetAtt DefaultCloudfrontDistribution.DomainName, "'" ]]
]]
passthroughBehavior: when_no_match
Expand Down Expand Up @@ -458,7 +458,7 @@ Resources:
method.response.header.Access-Control-Allow-Headers: "'Content-Type,Authorization,X-Amz-Date,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Origin: !If [ 'DevelopmentMode', "'*'", !If [
'UseCustomDomainName',
!Join ['', [ "'https://", !GetAtt CustomDomainCloudfrontDistribution.DomainName, "'" ]],
!Join ['', [ "'https://", !Ref CustomDomainName, "'" ]],
!Join ['', [ "'https://", !GetAtt DefaultCloudfrontDistribution.DomainName, "'" ]]
]]
passthroughBehavior: when_no_match
Expand Down Expand Up @@ -510,7 +510,7 @@ Resources:
method.response.header.Access-Control-Allow-Headers: "'Content-Type,Authorization,X-Amz-Date,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Origin: !If [ 'DevelopmentMode', "'*'", !If [
'UseCustomDomainName',
!Join ['', [ "'https://", !GetAtt CustomDomainCloudfrontDistribution.DomainName, "'" ]],
!Join ['', [ "'https://", !Ref CustomDomainName, "'" ]],
!Join ['', [ "'https://", !GetAtt DefaultCloudfrontDistribution.DomainName, "'" ]]
]]
passthroughBehavior: when_no_match
Expand Down Expand Up @@ -1366,7 +1366,6 @@ Resources:
DistributionConfig:
Aliases:
- !Ref CustomDomainName
- !Join [ '', [ 'www.', !Ref CustomDomainName ] ]
CustomErrorResponses:
- ErrorCode: 403
ResponseCode: 403
Expand Down Expand Up @@ -1443,19 +1442,14 @@ Resources:
# this is a "magic string" for using CFN aliases; see this link:
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-aliastarget.html
HostedZoneId: 'Z2FDTNDATAQYW2'
- Name: !Join [ '', [ 'www.', !Ref CustomDomainName, '.' ] ]
Type: A
AliasTarget:
DNSName: !Join [ '', [ !GetAtt CustomDomainCloudfrontDistribution.DomainName, '.' ] ]
HostedZoneId: 'Z2FDTNDATAQYW2'

Outputs:
WebsiteURL:
Value: !If [ 'DevelopmentMode',
!Join [ '', [ 'https://', !GetAtt DevPortalSiteS3Bucket.RegionalDomainName, '/index.html' ]],
!If [
'UseCustomDomainName',
!Join [ '', [ 'https://', !GetAtt CustomDomainCloudfrontDistribution.DomainName ]],
!Join [ '', [ 'https://', !Ref CustomDomainName ]],
!Join [ '', [ 'https://', !GetAtt DefaultCloudfrontDistribution.DomainName ]]
]
]
Expand Down