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

fix(nextjs-cdk-construct): use posix paths for s3 assets and invalida… #1025

Merged
merged 1 commit into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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