Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

CDK Construct - S3 Deployment stage missing basePath #1620

Open
@ghsyeung

Description

@ghsyeung

If basePath is set in next.config.js, the build would put static assets within ${sererlessBuildOutDir}/assets/${basePath}.

However, in the CDK construct (NextJSLambdaEdge), it tries to read the assets from ${sererlessBuildOutDir}/assets without including the basePath

const assets = readAssetsDirectory({ assetsDirectory });

The function returns with an empty assets object leading to none of the assets being uploaded.

Similar code in s3-static-assets handle this correctly

path.join(assetsOutputDirectory, normalizedBasePath, "_next", "static")

The fix looks relatively straight forward and it works for my use case.

const { basePath } = this.routesManifest || {};
const normalizedBasePath = basePath && basePath.length > 0? basePath.slice(1) : "";
const assets = readAssetsDirectory({ assetsDirectory: path.join(assetsDirectory, normalizedBasePath) }); 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions