diff --git a/.changeset/eleven-books-yawn.md b/.changeset/eleven-books-yawn.md new file mode 100644 index 00000000..89243f67 --- /dev/null +++ b/.changeset/eleven-books-yawn.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/aws": patch +--- + +fix cache interceptor for index page diff --git a/packages/open-next/src/core/routing/cacheInterceptor.ts b/packages/open-next/src/core/routing/cacheInterceptor.ts index 9a2aaf88..cf441331 100644 --- a/packages/open-next/src/core/routing/cacheInterceptor.ts +++ b/packages/open-next/src/core/routing/cacheInterceptor.ts @@ -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) {