Skip to content

Commit a80144b

Browse files
committed
chore: wip
1 parent a3d818c commit a80144b

File tree

1 file changed

+13
-17
lines changed
  • storage/framework/core/cloud/src/cloud

1 file changed

+13
-17
lines changed

storage/framework/core/cloud/src/cloud/cdn.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,14 @@ export class CdnStack {
239239

240240
apiBehaviorOptions(scope: Construct, props: CdnStackProps): Record<string, cloudfront.BehaviorOptions> {
241241
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+
})
249246

250247
return {
251248
'/api': {
252-
origin: origin(),
249+
origin,
253250
compress: true,
254251
allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
255252
cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD_OPTIONS,
@@ -259,7 +256,7 @@ export class CdnStack {
259256
},
260257

261258
'/api/*': {
262-
origin: origin(),
259+
origin,
263260
compress: true,
264261
allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
265262
cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD_OPTIONS,
@@ -273,12 +270,14 @@ export class CdnStack {
273270
docsBehaviorOptions(docsBucket?: s3.Bucket): Record<string, cloudfront.BehaviorOptions> {
274271
if (!docsBucket) return {}
275272

273+
const origin = new origins.S3Origin(docsBucket, {
274+
originAccessIdentity: this.originAccessIdentity,
275+
originPath: '/docs',
276+
})
277+
276278
return {
277279
'/docs': {
278-
origin: new origins.S3Origin(docsBucket, {
279-
originAccessIdentity: this.originAccessIdentity,
280-
originPath: '/docs',
281-
}),
280+
origin,
282281
compress: true,
283282
allowedMethods: this.allowedMethodsFromString(config.cloud.cdn?.allowedMethods),
284283
cachedMethods: this.cachedMethodsFromString(config.cloud.cdn?.cachedMethods),
@@ -288,10 +287,7 @@ export class CdnStack {
288287
},
289288

290289
'/docs/*': {
291-
origin: new origins.S3Origin(docsBucket, {
292-
originAccessIdentity: this.originAccessIdentity,
293-
originPath: '/docs',
294-
}),
290+
origin,
295291
compress: true,
296292
allowedMethods: this.allowedMethodsFromString(config.cloud.cdn?.allowedMethods),
297293
cachedMethods: this.cachedMethodsFromString(config.cloud.cdn?.cachedMethods),

0 commit comments

Comments
 (0)