From b12e77b72e6b846429bb984add89351a42b655e4 Mon Sep 17 00:00:00 2001 From: ousama Date: Mon, 21 Sep 2026 16:44:31 +0100 Subject: [PATCH 1/2] [Pages] Document wildcards before a file extension in `_routes.json` --- src/content/docs/pages/functions/routing.mdx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/content/docs/pages/functions/routing.mdx b/src/content/docs/pages/functions/routing.mdx index cca5cb13bbf..0e4b2077727 100644 --- a/src/content/docs/pages/functions/routing.mdx +++ b/src/content/docs/pages/functions/routing.mdx @@ -160,7 +160,7 @@ This file will include three different properties: :::note -Wildcards match any number of path segments (slashes). For example, `/users/*` will match everything after the`/users/` path. +Wildcards match any number of path segments (slashes). For example, `/users/*` will match everything after the `/users/` path. ::: @@ -188,6 +188,16 @@ Below is another example of a `_routes.json` file. Any route inside the `/build` } ``` +A wildcard can also come before a file extension, and it matches at any depth. Use this when static files and Function routes share a path, such as an API that serves pre-rendered `.json` files beside routes a Function answers. In the example below, `/api/users/1.json` and `/api/users/1/posts.json` are served as static assets without invoking the Function, while `/api/users/1` and `/api/search` invoke it. + +```json +{ + "version": 1, + "include": ["/api/*"], + "exclude": ["/api/*.json"] +} +``` + ## Fail open / closed If on the Workers Free plan, you can configure how Pages behaves when your daily free tier allowance of Pages Functions requests is exhausted. If, for example, you are performing authentication checks or other critical functionality in your Pages Functions, you may wish to disable your Pages project when the allowance is exhausted. From f5e142665dd997c79cbee6f282234394cc872577 Mon Sep 17 00:00:00 2001 From: ousama Date: Mon, 21 Sep 2026 16:49:39 +0100 Subject: [PATCH 2/2] [Pages] Refer to the `_routes.json` example without a directional word --- src/content/docs/pages/functions/routing.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/pages/functions/routing.mdx b/src/content/docs/pages/functions/routing.mdx index 0e4b2077727..0164d336c47 100644 --- a/src/content/docs/pages/functions/routing.mdx +++ b/src/content/docs/pages/functions/routing.mdx @@ -188,7 +188,7 @@ Below is another example of a `_routes.json` file. Any route inside the `/build` } ``` -A wildcard can also come before a file extension, and it matches at any depth. Use this when static files and Function routes share a path, such as an API that serves pre-rendered `.json` files beside routes a Function answers. In the example below, `/api/users/1.json` and `/api/users/1/posts.json` are served as static assets without invoking the Function, while `/api/users/1` and `/api/search` invoke it. +A wildcard can also come before a file extension, and it matches at any depth. Use this when static files and Function routes share a path, such as an API that serves pre-rendered `.json` files beside routes a Function answers. With this `_routes.json`, `/api/users/1.json` and `/api/users/1/posts.json` are served as static assets without invoking the Function, while `/api/users/1` and `/api/search` invoke it: ```json {