Skip to content

Commit 493e18b

Browse files
authored
fix(instrumentation): handle "/" route correctly in App Router (#17) (#18)
* fix(instrumentation): handle "/" route correctly in App Router (#17) * chore: remove leftover issue reference comment (#17) * refactor: use isAppRouter helper in route check
1 parent 6983f82 commit 493e18b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/nextjs-cache-handler/src/instrumentation/register-initial-cache.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,13 @@ export async function registerInitialCache(
231231
router: Router,
232232
revalidate: Revalidate,
233233
) {
234-
const pathToRouteFiles = path.join(serverDistDir, router, cachePath);
235-
236234
const isAppRouter = router === "app";
235+
236+
if (isAppRouter && cachePath === "/") {
237+
cachePath = "/index";
238+
}
239+
240+
const pathToRouteFiles = path.join(serverDistDir, router, cachePath);
237241

238242
let lastModified: number | undefined;
239243

0 commit comments

Comments
 (0)