Skip to content

Commit 3b23495

Browse files
conico974Nicolas Dorseuil
andauthored
Fix preview mode handling in cache interceptor (#935)
* Fix preview mode for cache interceptor * changeset --------- Co-authored-by: Nicolas Dorseuil <[email protected]>
1 parent c48ac95 commit 3b23495

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

.changeset/hot-ducks-burn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/aws": patch
3+
---
4+
5+
Fix preview mode in cache interceptor

packages/open-next/src/core/routing/cacheInterceptor.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,17 @@ export async function cacheInterceptor(
185185
Boolean(event.headers["x-prerender-revalidate"])
186186
)
187187
return event;
188+
189+
// Check for Next.js preview mode cookies
190+
const cookies = event.headers.cookie || "";
191+
const hasPreviewData =
192+
cookies.includes("__prerender_bypass") ||
193+
cookies.includes("__next_preview_data");
194+
195+
if (hasPreviewData) {
196+
debug("Preview mode detected, passing through to handler");
197+
return event;
198+
}
188199
// We localize the path in case i18n is enabled
189200
let localizedPath = localizePath(event);
190201
// If using basePath we need to remove it from the path

0 commit comments

Comments
 (0)