File tree 2 files changed +18
-1
lines changed
packages/adapter-cloudflare 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,18 @@ import './ambient.js';
4
4
export default function plugin ( options ?: AdapterOptions ) : Adapter ;
5
5
6
6
export interface AdapterOptions {
7
+ /**
8
+ * Whether to render a plaintext 404.html page, or a rendered SPA fallback page. This page will
9
+ * only be served when a request that matches an entry in `routes.exclude` fails to match an asset.
10
+ *
11
+ * Most of the time `plaintext` is sufficient, but if you are using `routes.exclude` to manually
12
+ * exclude a set of prerendered pages without exceeding the 100 route limit, you may wish to
13
+ * use `spa` instead.
14
+ *
15
+ * @default 'plaintext'
16
+ */
17
+ fallback ?: 'plaintext' | 'spa' ;
18
+
7
19
/**
8
20
* Customize the automatically-generated `_routes.json` file
9
21
* https://developers.cloudflare.com/pages/platform/functions/routing/#create-a-_routesjson-file
Original file line number Diff line number Diff line change @@ -19,7 +19,12 @@ export default function (options = {}) {
19
19
builder . mkdirp ( tmp ) ;
20
20
21
21
// generate plaintext 404.html first which can then be overridden by prerendering, if the user defined such a page
22
- writeFileSync ( `${ dest } /404.html` , 'Not Found' ) ;
22
+ const fallback = path . join ( dest , '404.html' ) ;
23
+ if ( options . fallback === 'spa' ) {
24
+ await builder . generateFallback ( fallback ) ;
25
+ } else {
26
+ writeFileSync ( fallback , 'Not Found' ) ;
27
+ }
23
28
24
29
const dest_dir = `${ dest } ${ builder . config . kit . paths . base } ` ;
25
30
const written_files = builder . writeClient ( dest_dir ) ;
You can’t perform that action at this time.
0 commit comments