From 377cd3633cfd323d42faaecf11df5342002fc0d0 Mon Sep 17 00:00:00 2001 From: Ben Stickley <35735118+bestickley@users.noreply.github.com> Date: Sat, 13 Jul 2024 06:22:11 -0400 Subject: [PATCH 1/5] Change prune default to false to fix 404s --- src/NextjsBucketDeployment.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/NextjsBucketDeployment.ts b/src/NextjsBucketDeployment.ts index e2569f36..211a6baa 100644 --- a/src/NextjsBucketDeployment.ts +++ b/src/NextjsBucketDeployment.ts @@ -29,7 +29,10 @@ export interface NextjsBucketDeploymentProps { * Old objects are determined by listing objects * in bucket before creating new objects and finding the objects that aren't in * the new objects. - * @default true + * + * Note, if this is set to true then clients who have old HTML files (browser tabs opened before deployment) + * will reference JS, CSS files that do not exist in S3 reslting in 404s. + * @default false */ readonly prune?: boolean | undefined; /** @@ -143,7 +146,7 @@ export class NextjsBucketDeployment extends Construct { destinationBucketName: this.props.destinationBucket.bucketName, destinationKeyPrefix: this.props.destinationKeyPrefix, putConfig: this.props.putConfig, - prune: this.props.prune, + prune: this.props.prune ?? true, substitutionConfig: this.props.substitutionConfig, zip: this.props.zip, }; From 6f1575f85ad23bbcb6bb03ab02e96e994b3cf014 Mon Sep 17 00:00:00 2001 From: Ben Stickley <35735118+bestickley@users.noreply.github.com> Date: Sat, 13 Jul 2024 06:25:09 -0400 Subject: [PATCH 2/5] Update NextjsBucketDeployment.ts --- src/NextjsBucketDeployment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NextjsBucketDeployment.ts b/src/NextjsBucketDeployment.ts index 211a6baa..3a3bcdad 100644 --- a/src/NextjsBucketDeployment.ts +++ b/src/NextjsBucketDeployment.ts @@ -146,7 +146,7 @@ export class NextjsBucketDeployment extends Construct { destinationBucketName: this.props.destinationBucket.bucketName, destinationKeyPrefix: this.props.destinationKeyPrefix, putConfig: this.props.putConfig, - prune: this.props.prune ?? true, + prune: this.props.prune, substitutionConfig: this.props.substitutionConfig, zip: this.props.zip, }; From 4dbaf09fdc88c1d3b246fe70c219b1ca8904b5ee Mon Sep 17 00:00:00 2001 From: github-actions Date: Sat, 13 Jul 2024 10:25:17 +0000 Subject: [PATCH 3/5] chore: self mutation Signed-off-by: github-actions --- API.md | 10 ++++++++-- .../OptionalNextjsBucketDeploymentProps.ts | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/API.md b/API.md index c5605e10..499a20fb 100644 --- a/API.md +++ b/API.md @@ -2713,7 +2713,7 @@ public readonly prune: boolean; ``` - *Type:* boolean -- *Default:* true +- *Default:* false If `true`, then delete old objects in `destinationBucket`/`destinationKeyPrefix` **after** uploading new objects. Only applies if `zip` is `false`. @@ -2721,6 +2721,9 @@ Old objects are determined by listing objects in bucket before creating new objects and finding the objects that aren't in the new objects. +Note, if this is set to true then clients who have old HTML files (browser tabs opened before deployment) +will reference JS, CSS files that do not exist in S3 reslting in 404s. + --- ##### `putConfig`Optional @@ -7520,7 +7523,7 @@ public readonly prune: boolean; ``` - *Type:* boolean -- *Default:* true +- *Default:* false If `true`, then delete old objects in `destinationBucket`/`destinationKeyPrefix` **after** uploading new objects. @@ -7529,6 +7532,9 @@ Old objects are determined by listing objects in bucket before creating new objects and finding the objects that aren't in the new objects. +Note, if this is set to true then clients who have old HTML files (browser tabs opened before deployment) +will reference JS, CSS files that do not exist in S3 reslting in 404s. + --- ##### `putConfig`Optional diff --git a/src/generated-structs/OptionalNextjsBucketDeploymentProps.ts b/src/generated-structs/OptionalNextjsBucketDeploymentProps.ts index 39f0ca42..d0a6ab02 100644 --- a/src/generated-structs/OptionalNextjsBucketDeploymentProps.ts +++ b/src/generated-structs/OptionalNextjsBucketDeploymentProps.ts @@ -38,7 +38,10 @@ export interface OptionalNextjsBucketDeploymentProps { * Old objects are determined by listing objects * in bucket before creating new objects and finding the objects that aren't in * the new objects. - * @default true + * + * Note, if this is set to true then clients who have old HTML files (browser tabs opened before deployment) + * will reference JS, CSS files that do not exist in S3 reslting in 404s. + * @default false * @stability stable */ readonly prune?: boolean; From 23f300477b1ce2dab93828af6e5cc8f67ccffa94 Mon Sep 17 00:00:00 2001 From: Ben Stickley <35735118+bestickley@users.noreply.github.com> Date: Sat, 13 Jul 2024 06:26:49 -0400 Subject: [PATCH 4/5] Update NextjsStaticAssets.ts --- src/NextjsStaticAssets.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NextjsStaticAssets.ts b/src/NextjsStaticAssets.ts index eecefd97..880badb9 100644 --- a/src/NextjsStaticAssets.ts +++ b/src/NextjsStaticAssets.ts @@ -127,7 +127,7 @@ export class NextjsStaticAssets extends Construct { // only put env vars that are placeholders in custom resource properties // to be replaced. other env vars were injected at build time. substitutionConfig: NextjsBucketDeployment.getSubstitutionConfig(this.buildEnvVars), - prune: this.props.prune === false ? false : true, // default to true + prune: this.props.prune, // defaults to false putConfig: { [allFiles]: { CacheControl: 'public, max-age=0, must-revalidate', From dd1672dfed1aef6156bec3b354c05dbfcc03edcc Mon Sep 17 00:00:00 2001 From: Ben Stickley <35735118+bestickley@users.noreply.github.com> Date: Sat, 13 Jul 2024 06:27:11 -0400 Subject: [PATCH 5/5] Update NextjsBucketDeployment.ts --- src/NextjsBucketDeployment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NextjsBucketDeployment.ts b/src/NextjsBucketDeployment.ts index 3a3bcdad..577abd7b 100644 --- a/src/NextjsBucketDeployment.ts +++ b/src/NextjsBucketDeployment.ts @@ -146,7 +146,7 @@ export class NextjsBucketDeployment extends Construct { destinationBucketName: this.props.destinationBucket.bucketName, destinationKeyPrefix: this.props.destinationKeyPrefix, putConfig: this.props.putConfig, - prune: this.props.prune, + prune: this.props.prune ?? false, substitutionConfig: this.props.substitutionConfig, zip: this.props.zip, };