Skip to content

Commit 957bb47

Browse files
GregBrimbleOxyjun
andauthored
Pages Functions Fail open/closed docs (#22331)
* Fail open/closed docs * Apply suggestions from code review Co-authored-by: Jun Lee <[email protected]> --------- Co-authored-by: Jun Lee <[email protected]>
1 parent aab964c commit 957bb47

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

src/content/docs/pages/functions/routing.mdx

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ import { FileTree } from "~/components";
1515
Functions utilize file-based routing. Your `/functions` directory structure determines the designated routes that your Functions will run on. You can create a `/functions` directory with as many levels as needed for your project's use case. Review the following directory:
1616

1717
<FileTree>
18+
1819
- ...
1920
- functions
20-
- index.js
21-
- helloworld.js
22-
- howdyworld.js
23-
- fruits
24-
- index.js
25-
- apple.js
26-
- banana.js
21+
- index.js
22+
- helloworld.js
23+
- howdyworld.js
24+
- fruits
25+
- index.js
26+
- apple.js
27+
- banana.js
28+
2729
</FileTree>
2830

2931
The following routes will be generated based on the above file structure. These routes map the URL pattern to the `/functions` file that will be invoked when a visitor goes to the URL:
@@ -85,13 +87,15 @@ More specific routes (routes with fewer wildcards) take precedence over less spe
8587
Review the following `/functions/` directory structure:
8688

8789
<FileTree>
90+
8891
- ...
8992
- functions
90-
- date.js
91-
- users
92-
- special.js
93-
- [user].js
94-
- [[catchall]].js
93+
- date.js
94+
- users
95+
- special.js
96+
- [user].js
97+
- [[catchall]].js
98+
9599
</FileTree>
96100

97101
The following requests will match the following files:
@@ -177,6 +181,19 @@ Below is another example of a `_routes.json` file. Any route inside the `/build`
177181
}
178182
```
179183

184+
## Fail open / closed
185+
186+
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.
187+
188+
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
189+
2. From **Account Home**, go to **Workers & Pages**.
190+
3. In **Overview**, select your Pages project.
191+
4. Go to **Settings** > **Runtime** > **Fail open / closed**.
192+
193+
"Fail open" means that static assets will continue to be served, even if Pages Functions would ordinarily have run first. "Fail closed" means an error page will be returned, rather than static assets.
194+
195+
The daily request limit for Pages Functions can be removed entirely by upgrading to [Workers Standard](/workers/platform/pricing/#workers).
196+
180197
### Limits
181198

182199
Functions invocation routes have the following limits:

0 commit comments

Comments
 (0)