From cf780e983e8e8e367d891b1d365d3b2782bae9cb Mon Sep 17 00:00:00 2001 From: Robert van Kempen Date: Wed, 19 Jan 2022 02:06:49 +0100 Subject: [PATCH] fix(nextjs-cdk-construct): use basepath in s3 assets (#2265) --- .../serverless-components/nextjs-cdk-construct/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/serverless-components/nextjs-cdk-construct/src/index.ts b/packages/serverless-components/nextjs-cdk-construct/src/index.ts index e67ee4b278..0136ace602 100644 --- a/packages/serverless-components/nextjs-cdk-construct/src/index.ts +++ b/packages/serverless-components/nextjs-cdk-construct/src/index.ts @@ -406,7 +406,9 @@ export class NextJSLambdaEdge extends Construct { ); const assetsDirectory = path.join(props.serverlessBuildOutDir, "assets"); - const assets = readAssetsDirectory({ assetsDirectory }); + const { basePath } = this.routesManifest || {}; + const normalizedBasePath = basePath && basePath.length > 0 ? basePath.slice(1) : ""; + const assets = readAssetsDirectory({ assetsDirectory: path.join(assetsDirectory, normalizedBasePath) }); // This `BucketDeployment` deploys just the BUILD_ID file. We don't actually // use the BUILD_ID file at runtime, however in this case we use it as a