Skip to content

Commit 3cb566e

Browse files
authored
fix(cloudflare-pages): use predefined wildcards in routes.exclude (#2319)
1 parent 91ef6d0 commit 3cb566e

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

src/presets/cloudflare-pages.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ async function writeCFRoutes(nitro: Nitro) {
120120
"_worker.js",
121121
"_worker.js.map",
122122
"nitro.json",
123-
...explicitPublicAssets.map((dir) =>
124-
withoutLeadingSlash(joinURL(dir.baseURL, "**"))
123+
...routes.exclude.map((path) =>
124+
withoutLeadingSlash(path.replace(/\/\*$/, "/**"))
125125
),
126126
],
127127
});

test/fixture/nitro.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default defineNitroConfig({
107107
pages: {
108108
routes: {
109109
include: ["/*"],
110-
exclude: ["/blog/static/*"],
110+
exclude: ["/blog/static/*", "/cf-pages-exclude/*"],
111111
},
112112
},
113113
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This file shouldn't be under "exclude" in the _routes.json outputted by Cloudflare Pages builds.
2+
It's covered by the "/cf-pages-exclude/*" wildcard.

test/presets/cloudflare-pages.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ describe.skipIf(isWindows)("nitro:preset:cloudflare-pages", async () => {
3939
{
4040
"exclude": [
4141
"/blog/static/*",
42+
"/cf-pages-exclude/*",
4243
"/build/*",
4344
"/_unignored.txt",
4445
"/favicon.ico",

0 commit comments

Comments
 (0)