Skip to content

Commit

Permalink
fix(cloudflare-pages): remove .html extension from _routes.json (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux authored and pi0 committed Jun 27, 2024
1 parent 4e79242 commit 1b8a8ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@
]
}
}
}
}
12 changes: 10 additions & 2 deletions src/presets/cloudflare-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,16 @@ async function writeCFRoutes(nitro: Nitro) {
),
],
});
routes.exclude.push(
...publicAssetFiles.map((i) => withLeadingSlash(i)).sort(comparePaths)
// Remove index.html or the .html extension to support pages pre-rendering
routes.exclude!.push(
...publicAssetFiles
.map(
(i) =>
withLeadingSlash(i)
.replace(/\/index\.html$/, "")
.replace(/\.html$/, "") || "/"
)
.sort(comparePaths)
);

// Only allow 100 rules in total (include + exclude)
Expand Down
4 changes: 2 additions & 2 deletions test/presets/cloudflare-pages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ describe.skipIf(isWindows)("nitro:preset:cloudflare-pages", async () => {
"/_unignored.txt",
"/favicon.ico",
"/json-string",
"/prerender",
"/api/hello",
"/prerender/index.html",
"/api/hey",
"/prerender/index.html.br",
"/prerender/index.html.gz",
"/api/hey/index.html",
"/api/param/foo.json",
"/api/param/hidden",
"/api/param/prerender1",
Expand Down

0 comments on commit 1b8a8ea

Please sign in to comment.