sst 2.8.2 → 2.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constructs/NextjsSite.js +14 -2
- package/constructs/SsrSite.d.ts +1 -1
- package/constructs/SsrSite.js +4 -2
- package/package.json +1 -1
package/constructs/NextjsSite.js
CHANGED
|
@@ -153,7 +153,13 @@ export class NextjsSite extends SsrSite {
|
|
|
153
153
|
authType: FunctionUrlAuthType.NONE,
|
|
154
154
|
});
|
|
155
155
|
const serverOrigin = new HttpOrigin(Fn.parseDomainName(serverFnUrl.url));
|
|
156
|
-
const cachePolicy = cdk?.serverCachePolicy ??
|
|
156
|
+
const cachePolicy = cdk?.serverCachePolicy ??
|
|
157
|
+
this.buildServerCachePolicy([
|
|
158
|
+
"accept",
|
|
159
|
+
"rsc",
|
|
160
|
+
"next-router-prefetch",
|
|
161
|
+
"next-router-state-tree",
|
|
162
|
+
]);
|
|
157
163
|
const originRequestPolicy = this.buildServerOriginRequestPolicy();
|
|
158
164
|
const serverBehavior = this.buildServerBehaviorForRegional(serverOrigin, cachePolicy, originRequestPolicy);
|
|
159
165
|
return new Distribution(this, "Distribution", {
|
|
@@ -178,7 +184,13 @@ export class NextjsSite extends SsrSite {
|
|
|
178
184
|
const { cdk } = this.props;
|
|
179
185
|
const cfDistributionProps = cdk?.distribution || {};
|
|
180
186
|
const s3Origin = new S3Origin(this.cdk.bucket);
|
|
181
|
-
const cachePolicy = cdk?.serverCachePolicy ??
|
|
187
|
+
const cachePolicy = cdk?.serverCachePolicy ??
|
|
188
|
+
this.buildServerCachePolicy([
|
|
189
|
+
"accept",
|
|
190
|
+
"rsc",
|
|
191
|
+
"next-router-prefetch",
|
|
192
|
+
"next-router-state-tree",
|
|
193
|
+
]);
|
|
182
194
|
const originRequestPolicy = this.buildServerOriginRequestPolicy();
|
|
183
195
|
const functionVersion = this.serverLambdaForEdge.currentVersion;
|
|
184
196
|
const serverBehavior = this.buildServerBehaviorForEdge(functionVersion, s3Origin, cachePolicy, originRequestPolicy);
|
package/constructs/SsrSite.d.ts
CHANGED
|
@@ -276,7 +276,7 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
276
276
|
function: CfFunction;
|
|
277
277
|
}[];
|
|
278
278
|
private buildStaticFileBehaviors;
|
|
279
|
-
protected buildServerCachePolicy(): CachePolicy;
|
|
279
|
+
protected buildServerCachePolicy(allowedHeaders?: string[]): CachePolicy;
|
|
280
280
|
protected buildServerOriginRequestPolicy(): import("aws-cdk-lib/aws-cloudfront").IOriginRequestPolicy;
|
|
281
281
|
private createCloudFrontInvalidation;
|
|
282
282
|
protected validateCustomDomainSettings(): void;
|
package/constructs/SsrSite.js
CHANGED
|
@@ -608,10 +608,12 @@ function handler(event) {
|
|
|
608
608
|
}
|
|
609
609
|
return staticsBehaviours;
|
|
610
610
|
}
|
|
611
|
-
buildServerCachePolicy() {
|
|
611
|
+
buildServerCachePolicy(allowedHeaders) {
|
|
612
612
|
return new CachePolicy(this, "ServerCache", {
|
|
613
613
|
queryStringBehavior: CacheQueryStringBehavior.all(),
|
|
614
|
-
headerBehavior:
|
|
614
|
+
headerBehavior: allowedHeaders && allowedHeaders.length > 0
|
|
615
|
+
? CacheHeaderBehavior.allowList(...allowedHeaders)
|
|
616
|
+
: CacheHeaderBehavior.none(),
|
|
615
617
|
cookieBehavior: CacheCookieBehavior.all(),
|
|
616
618
|
defaultTtl: CdkDuration.days(0),
|
|
617
619
|
maxTtl: CdkDuration.days(365),
|