@@ -3,9 +3,11 @@ import { CfnOutput, Duration, Stack } from 'aws-cdk-lib'
3
3
import { ICertificate } from 'aws-cdk-lib/aws-certificatemanager'
4
4
import {
5
5
AllowedMethods ,
6
+ BehaviorOptions ,
6
7
CacheCookieBehavior ,
7
8
CacheHeaderBehavior ,
8
9
CachePolicy ,
10
+ CachePolicyProps ,
9
11
CacheQueryStringBehavior ,
10
12
Distribution ,
11
13
IOrigin ,
@@ -37,12 +39,12 @@ export const setupCfnDistro = (
37
39
const imageOrigin = new HttpOrigin ( apiGwDomainName , { originPath : imageBasePath } )
38
40
const assetsOrigin = new S3Origin ( assetsBucket )
39
41
40
- const defaultOptions = {
42
+ const defaultOptions : Partial < BehaviorOptions > = {
41
43
viewerProtocolPolicy : ViewerProtocolPolicy . REDIRECT_TO_HTTPS ,
42
44
allowedMethods : AllowedMethods . ALLOW_GET_HEAD_OPTIONS ,
43
45
}
44
46
45
- const defaultCacheOptions = {
47
+ const defaultCacheOptions : Partial < CachePolicyProps > = {
46
48
headerBehavior : CacheHeaderBehavior . allowList ( 'accept' , 'accept-language' , 'content-language' , 'content-type' , 'user-agent' , 'authorization' ) ,
47
49
queryStringBehavior : CacheQueryStringBehavior . all ( ) ,
48
50
cookieBehavior : CacheCookieBehavior . all ( ) ,
@@ -58,12 +60,6 @@ export const setupCfnDistro = (
58
60
...defaultCacheOptions ,
59
61
} )
60
62
61
- const apiCachePolicy = new CachePolicy ( scope , 'NextApiCachePolicy' , {
62
- ...defaultCacheOptions ,
63
- maxTtl : Duration . seconds ( 0 ) ,
64
- defaultTtl : Duration . seconds ( 0 ) ,
65
- } )
66
-
67
63
// Public folder persists names so we are making default TTL lower for cases when invalidation does not happen.
68
64
const assetsCachePolicy = new CachePolicy ( scope , 'NextPublicCachePolicy' , {
69
65
queryStringBehavior : CacheQueryStringBehavior . all ( ) ,
@@ -91,7 +87,7 @@ export const setupCfnDistro = (
91
87
...defaultOptions ,
92
88
origin : customApiOrigin ?? serverOrigin ,
93
89
allowedMethods : AllowedMethods . ALLOW_ALL ,
94
- cachePolicy : apiCachePolicy ,
90
+ cachePolicy : CachePolicy . CACHING_DISABLED ,
95
91
} ,
96
92
'_next/data/*' : {
97
93
...defaultOptions ,
0 commit comments