Skip to content

Commit 54da239

Browse files
committed
Add CORS support to Dovetail CDN
1 parent a480306 commit 54da239

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

cdn/dovetail-cdn/cloudfront.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ Resources:
200200
CloudFrontCachePolicy:
201201
Type: AWS::CloudFront::CachePolicy
202202
Properties:
203+
# The headers, cookies, and query strings that are included in the
204+
# CACHE KEY (CachePolicyConfig) are also included in requests that
205+
# CloudFront sends to the origin.
203206
CachePolicyConfig:
204207
Comment: !Sub Policy for ${AWS::StackName}
205208
DefaultTTL: 86400
@@ -212,12 +215,19 @@ Resources:
212215
EnableAcceptEncodingBrotli: false
213216
EnableAcceptEncodingGzip: false
214217
HeadersConfig:
215-
HeaderBehavior: none
218+
HeaderBehavior: whitelist
219+
Headers:
220+
- Origin
221+
- Access-Control-Request-Headers
222+
- Access-Control-Request-Method
216223
QueryStringsConfig:
217224
QueryStringBehavior: none
218225
CloudFrontOriginRequestPolicy:
219226
Type: AWS::CloudFront::OriginRequestPolicy
220227
Properties:
228+
# The headers, cookies, and query strings that are included in the
229+
# CACHE KEY (CachePolicyConfig) are also included in requests that
230+
# CloudFront sends to the origin.
221231
OriginRequestPolicyConfig:
222232
Comment: !Sub Policy for ${AWS::StackName}
223233
CookiesConfig:
@@ -331,8 +341,8 @@ Resources:
331341
CacheBehaviors:
332342
- Fn::If:
333343
- HasRegion1
334-
- AllowedMethods: [HEAD, GET]
335-
CachedMethods: [HEAD, GET]
344+
- AllowedMethods: [HEAD, GET, OPTIONS]
345+
CachedMethods: [HEAD, GET, OPTIONS]
336346
CachePolicyId: !Ref CloudFrontCachePolicy
337347
Compress: false
338348
FunctionAssociations:
@@ -349,8 +359,8 @@ Resources:
349359
- !Ref AWS::NoValue
350360
- Fn::If:
351361
- HasRegion2
352-
- AllowedMethods: [HEAD, GET]
353-
CachedMethods: [HEAD, GET]
362+
- AllowedMethods: [HEAD, GET, OPTIONS]
363+
CachedMethods: [HEAD, GET, OPTIONS]
354364
CachePolicyId: !Ref CloudFrontCachePolicy
355365
Compress: false
356366
FunctionAssociations:
@@ -367,8 +377,8 @@ Resources:
367377
- !Ref AWS::NoValue
368378
- Fn::If:
369379
- HasRegion3
370-
- AllowedMethods: [HEAD, GET]
371-
CachedMethods: [HEAD, GET]
380+
- AllowedMethods: [HEAD, GET, OPTIONS]
381+
CachedMethods: [HEAD, GET, OPTIONS]
372382
CachePolicyId: !Ref CloudFrontCachePolicy
373383
Compress: false
374384
FunctionAssociations:

spire/templates/apps/dovetail-cdn-arranger.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ Resources:
4343
DeletionPolicy: Retain
4444
UpdateReplacePolicy: Retain
4545
Properties:
46+
CorsConfiguration:
47+
CorsRules:
48+
- AllowedHeaders:
49+
- "*"
50+
AllowedMethods:
51+
- GET
52+
- HEAD
53+
AllowedOrigins:
54+
- "*"
4655
LifecycleConfiguration:
4756
Rules:
4857
- ExpirationInDays: 1

0 commit comments

Comments
 (0)