Skip to content

Fix index page with cache interceptor #860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2025
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
5 changes: 5 additions & 0 deletions .changeset/eleven-books-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/aws": patch
---

fix cache interceptor for index page
10 changes: 4 additions & 6 deletions packages/open-next/src/core/routing/cacheInterceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,20 @@ export async function cacheInterceptor(
}
// We also need to remove trailing slash
localizedPath = localizedPath.replace(/\/$/, "");
// If empty path, it means we want index
if (localizedPath === "") {
localizedPath = "index";
}

debug("Checking cache for", localizedPath, PrerenderManifest);

const isISR =
Object.keys(PrerenderManifest.routes).includes(localizedPath) ||
Object.keys(PrerenderManifest.routes).includes(localizedPath ?? "/") ||
Object.values(PrerenderManifest.dynamicRoutes).some((dr) =>
new RegExp(dr.routeRegex).test(localizedPath),
);
debug("isISR", isISR);
if (isISR) {
try {
const cachedData = await globalThis.incrementalCache.get(localizedPath);
const cachedData = await globalThis.incrementalCache.get(
localizedPath ?? "/index",
);
debug("cached data in interceptor", cachedData);

if (!cachedData?.value) {
Expand Down
Loading