@@ -239,17 +239,14 @@ export class CdnStack {
239
239
240
240
apiBehaviorOptions ( scope : Construct , props : CdnStackProps ) : Record < string , cloudfront . BehaviorOptions > {
241
241
const hostname = `api.${ props . domain } ` // TODO: make `api` configurable
242
-
243
- const origin = ( ) => {
244
- return new origins . HttpOrigin ( hostname , {
245
- originPath : '/' ,
246
- protocolPolicy : cloudfront . OriginProtocolPolicy . HTTPS_ONLY ,
247
- } )
248
- }
242
+ const origin = new origins . HttpOrigin ( hostname , {
243
+ originPath : '/' ,
244
+ protocolPolicy : cloudfront . OriginProtocolPolicy . HTTPS_ONLY ,
245
+ } )
249
246
250
247
return {
251
248
'/api' : {
252
- origin : origin ( ) ,
249
+ origin,
253
250
compress : true ,
254
251
allowedMethods : cloudfront . AllowedMethods . ALLOW_ALL ,
255
252
cachedMethods : cloudfront . CachedMethods . CACHE_GET_HEAD_OPTIONS ,
@@ -259,7 +256,7 @@ export class CdnStack {
259
256
} ,
260
257
261
258
'/api/*' : {
262
- origin : origin ( ) ,
259
+ origin,
263
260
compress : true ,
264
261
allowedMethods : cloudfront . AllowedMethods . ALLOW_ALL ,
265
262
cachedMethods : cloudfront . CachedMethods . CACHE_GET_HEAD_OPTIONS ,
@@ -273,12 +270,14 @@ export class CdnStack {
273
270
docsBehaviorOptions ( docsBucket ?: s3 . Bucket ) : Record < string , cloudfront . BehaviorOptions > {
274
271
if ( ! docsBucket ) return { }
275
272
273
+ const origin = new origins . S3Origin ( docsBucket , {
274
+ originAccessIdentity : this . originAccessIdentity ,
275
+ originPath : '/docs' ,
276
+ } )
277
+
276
278
return {
277
279
'/docs' : {
278
- origin : new origins . S3Origin ( docsBucket , {
279
- originAccessIdentity : this . originAccessIdentity ,
280
- originPath : '/docs' ,
281
- } ) ,
280
+ origin,
282
281
compress : true ,
283
282
allowedMethods : this . allowedMethodsFromString ( config . cloud . cdn ?. allowedMethods ) ,
284
283
cachedMethods : this . cachedMethodsFromString ( config . cloud . cdn ?. cachedMethods ) ,
@@ -288,10 +287,7 @@ export class CdnStack {
288
287
} ,
289
288
290
289
'/docs/*' : {
291
- origin : new origins . S3Origin ( docsBucket , {
292
- originAccessIdentity : this . originAccessIdentity ,
293
- originPath : '/docs' ,
294
- } ) ,
290
+ origin,
295
291
compress : true ,
296
292
allowedMethods : this . allowedMethodsFromString ( config . cloud . cdn ?. allowedMethods ) ,
297
293
cachedMethods : this . cachedMethodsFromString ( config . cloud . cdn ?. cachedMethods ) ,
0 commit comments