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 Jun 7, 2024
1 parent 0112801 commit 79b85fe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@
"nitro": "./dist/cli/index.mjs",
"nitropack": "./dist/cli/index.mjs"
},
"files": [
"dist",
"*.d.ts",
"runtime-meta.*"
],
"files": ["dist", "*.d.ts", "runtime-meta.*"],
"scripts": {
"build": "pnpm gen-presets && unbuild",
"dev": "pnpm nitro dev playground",
Expand Down
10 changes: 9 additions & 1 deletion src/presets/cloudflare/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,16 @@ async function writeCFRoutes(nitro: Nitro) {
),
],
});
// Remove index.html or the .html extension to support pages pre-rendering
routes.exclude!.push(
...publicAssetFiles.map((i) => withLeadingSlash(i)).sort(comparePaths)
...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 79b85fe

Please sign in to comment.