From 4f2951d6699224d8fc1c0a3cfa0ca785ba5bc6dc Mon Sep 17 00:00:00 2001 From: Nicolas Dorseuil Date: Sun, 27 Jul 2025 22:33:55 +0200 Subject: [PATCH 1/2] Fix preview mode for cache interceptor --- .../open-next/src/core/routing/cacheInterceptor.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/open-next/src/core/routing/cacheInterceptor.ts b/packages/open-next/src/core/routing/cacheInterceptor.ts index 70dd083f8..7b616d5ca 100644 --- a/packages/open-next/src/core/routing/cacheInterceptor.ts +++ b/packages/open-next/src/core/routing/cacheInterceptor.ts @@ -185,6 +185,17 @@ export async function cacheInterceptor( Boolean(event.headers["x-prerender-revalidate"]) ) return event; + + // Check for Next.js preview mode cookies + const cookies = event.headers.cookie || ""; + const hasPreviewData = + cookies.includes("__prerender_bypass") || + cookies.includes("__next_preview_data"); + + if (hasPreviewData) { + debug("Preview mode detected, passing through to handler"); + return event; + } // We localize the path in case i18n is enabled let localizedPath = localizePath(event); // If using basePath we need to remove it from the path From b18b99bcdbb9961340b6b5db463a84d9d480b89b Mon Sep 17 00:00:00 2001 From: Nicolas Dorseuil Date: Sun, 27 Jul 2025 22:36:15 +0200 Subject: [PATCH 2/2] changeset --- .changeset/hot-ducks-burn.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/hot-ducks-burn.md diff --git a/.changeset/hot-ducks-burn.md b/.changeset/hot-ducks-burn.md new file mode 100644 index 000000000..a2b6d1ced --- /dev/null +++ b/.changeset/hot-ducks-burn.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/aws": patch +--- + +Fix preview mode in cache interceptor