Skip to content

Commit 2447024

Browse files
authored
Fix index page with cache interceptor (#860)
* fix index page cache interceptor * changeset
1 parent 1b78890 commit 2447024

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

.changeset/eleven-books-yawn.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 cache interceptor for index page

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,22 +146,20 @@ export async function cacheInterceptor(
146146
}
147147
// We also need to remove trailing slash
148148
localizedPath = localizedPath.replace(/\/$/, "");
149-
// If empty path, it means we want index
150-
if (localizedPath === "") {
151-
localizedPath = "index";
152-
}
153149

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

156152
const isISR =
157-
Object.keys(PrerenderManifest.routes).includes(localizedPath) ||
153+
Object.keys(PrerenderManifest.routes).includes(localizedPath ?? "/") ||
158154
Object.values(PrerenderManifest.dynamicRoutes).some((dr) =>
159155
new RegExp(dr.routeRegex).test(localizedPath),
160156
);
161157
debug("isISR", isISR);
162158
if (isISR) {
163159
try {
164-
const cachedData = await globalThis.incrementalCache.get(localizedPath);
160+
const cachedData = await globalThis.incrementalCache.get(
161+
localizedPath ?? "/index",
162+
);
165163
debug("cached data in interceptor", cachedData);
166164

167165
if (!cachedData?.value) {

0 commit comments

Comments
 (0)