@@ -20,6 +20,7 @@ export interface CdnStackProps extends NestedCloudProps {
20
20
webServerUrl : lambda . FunctionUrl
21
21
cliSetupUrl : lambda . FunctionUrl
22
22
askAiUrl : lambda . FunctionUrl
23
+ summarizeAiUrl : lambda . FunctionUrl
23
24
}
24
25
25
26
export class CdnStack {
@@ -244,40 +245,39 @@ export class CdnStack {
244
245
245
246
aiBehaviorOptions ( scope : Construct , props : CdnStackProps ) : Record < string , cloudfront . BehaviorOptions > {
246
247
const hostname = Fn . select ( 2 , Fn . split ( '/' , props . askAiUrl . url ) )
248
+ const summaryHostname = Fn . select ( 2 , Fn . split ( '/' , props . summarizeAiUrl . url ) )
249
+
250
+ const aiCachePolicy = new cloudfront . CachePolicy ( scope , 'AiCachePolicy' , {
251
+ comment : 'Stacks AI Cache Policy' ,
252
+ cachePolicyName : `${ this . props . slug } -${ this . props . appEnv } -ai-cache-policy` ,
253
+ defaultTtl : Duration . seconds ( 0 ) ,
254
+ // minTtl: config.cloud.cdn?.minTtl ? Duration.seconds(config.cloud.cdn.minTtl) : undefined,
255
+ cookieBehavior : cloudfront . CacheCookieBehavior . none ( ) ,
256
+ headerBehavior : cloudfront . CacheHeaderBehavior . allowList ( 'Accept' , 'x-api-key' , 'Authorization' , 'Content-Type' ) ,
257
+ queryStringBehavior : cloudfront . CacheQueryStringBehavior . all ( ) ,
258
+ } )
259
+
247
260
return {
248
261
'/ai/ask' : {
249
- // origin: new origins.HttpOrigin('9qp44a2b7e.execute-api.us-east-1.amazonaws.com', {
250
262
origin : new origins . HttpOrigin ( hostname , {
251
263
originPath : '/ai' ,
252
264
protocolPolicy : cloudfront . OriginProtocolPolicy . HTTPS_ONLY ,
253
265
} ) ,
254
266
compress : false ,
255
267
allowedMethods : cloudfront . AllowedMethods . ALLOW_ALL ,
256
268
viewerProtocolPolicy : cloudfront . ViewerProtocolPolicy . REDIRECT_TO_HTTPS ,
257
- cachePolicy : new cloudfront . CachePolicy ( scope , 'AiCachePolicy' , {
258
- comment : 'Stacks AI Cache Policy' ,
259
- cachePolicyName : `${ this . props . slug } -${ this . props . appEnv } -ai-cache-policy` ,
260
- defaultTtl : Duration . seconds ( 0 ) ,
261
- // minTtl: config.cloud.cdn?.minTtl ? Duration.seconds(config.cloud.cdn.minTtl) : undefined,
262
- cookieBehavior : cloudfront . CacheCookieBehavior . none ( ) ,
263
- headerBehavior : cloudfront . CacheHeaderBehavior . allowList ( 'Accept' , 'x-api-key' , 'Authorization' , 'Content-Type' ) ,
264
- queryStringBehavior : cloudfront . CacheQueryStringBehavior . all ( ) ,
269
+ cachePolicy : aiCachePolicy ,
270
+ } ,
271
+ '/ai/summary' : {
272
+ origin : new origins . HttpOrigin ( summaryHostname , {
273
+ originPath : '/ai' ,
274
+ protocolPolicy : cloudfront . OriginProtocolPolicy . HTTPS_ONLY ,
265
275
} ) ,
276
+ compress : false ,
277
+ allowedMethods : cloudfront . AllowedMethods . ALLOW_ALL ,
278
+ viewerProtocolPolicy : cloudfront . ViewerProtocolPolicy . REDIRECT_TO_HTTPS ,
279
+ cachePolicy : aiCachePolicy ,
266
280
} ,
267
- // '/ai/ask/*': {
268
- // origin,
269
- // compress: false,
270
- // allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
271
- // viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
272
- // cachePolicy: this.setApiCachePolicy(scope),
273
- // },
274
- // '/ai/summary': {
275
- // origin,
276
- // compress: false,
277
- // allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
278
- // viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
279
- // cachePolicy: this.setApiCachePolicy(scope),
280
- // },
281
281
}
282
282
}
283
283
0 commit comments