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

Commit

Permalink
fix(nextjs-cdk-construct): use posix paths for s3 assets and invalida…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
dphang committed Apr 28, 2021
1 parent f18d6a6 commit 35e6980
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ export class NextJSLambdaEdge extends cdk.Construct {
// The source contents will be unzipped to and loaded into the S3 bucket
// at the root '/', we don't want this, we want to maintain the same
// path on S3 as their local path.
destinationKeyPrefix: path.relative(assetsDirectory, assetPath),
destinationKeyPrefix: path.posix.relative(assetsDirectory, assetPath),

// Source directories are uploaded with `--sync` this means that any
// files that don't exist in the source directory, but do in the S3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ const readAssetsDirectory = (options: {
assetsDirectory: string;
}): CacheConfig => {
const { assetsDirectory } = options;
const publicFiles = path.join(assetsDirectory, "public");
const staticFiles = path.join(assetsDirectory, "static");
const staticPages = path.join(assetsDirectory, "static-pages");
const nextData = path.join(assetsDirectory, "_next", "data");
const nextStatic = path.join(assetsDirectory, "_next", "static");
// Ensure these are posix paths so they are compatible with AWS S3
const publicFiles = path.posix.join(assetsDirectory, "public");
const staticFiles = path.posix.join(assetsDirectory, "static");
const staticPages = path.posix.join(assetsDirectory, "static-pages");
const nextData = path.posix.join(assetsDirectory, "_next", "data");
const nextStatic = path.posix.join(assetsDirectory, "_next", "static");

return filterNonExistentPathKeys({
publicFiles: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { OriginRequestDefaultHandlerManifest } from "@sls-next/lambda-at-edge";

const dynamicPathToInvalidationPath = (dynamicPath: string) => {
const [firstSegment] = dynamicPath.split("/:");
return path.join(firstSegment || "/", "*");
// Ensure this is posix path as CloudFront needs forward slash in invalidation
return path.posix.join(firstSegment || "/", "*");
};

export const readInvalidationPathsFromManifest = (
Expand Down

0 comments on commit 35e6980

Please sign in to comment.