3
3
BaseOverride ,
4
4
LazyLoadedOverride ,
5
5
OpenNextConfig as AwsOpenNextConfig ,
6
+ type RoutePreloadingBehavior ,
6
7
} from "@opennextjs/aws/types/open-next" ;
7
8
import type {
8
9
CDNInvalidationHandler ,
@@ -45,6 +46,13 @@ export type CloudflareOverrides = {
45
46
* @default false
46
47
*/
47
48
enableCacheInterception ?: boolean ;
49
+
50
+ /**
51
+ * Route preloading behavior.
52
+ * Using a value other than "none" can result in higher CPU usage on cold starts.
53
+ * @default "none"
54
+ */
55
+ routePreloadingBehavior ?: RoutePreloadingBehavior ;
48
56
} ;
49
57
50
58
/**
@@ -54,7 +62,14 @@ export type CloudflareOverrides = {
54
62
* @returns the OpenNext configuration object
55
63
*/
56
64
export function defineCloudflareConfig ( config : CloudflareOverrides = { } ) : OpenNextConfig {
57
- const { incrementalCache, tagCache, queue, cachePurge, enableCacheInterception = false } = config ;
65
+ const {
66
+ incrementalCache,
67
+ tagCache,
68
+ queue,
69
+ cachePurge,
70
+ enableCacheInterception = false ,
71
+ routePreloadingBehavior = "none" ,
72
+ } = config ;
58
73
59
74
return {
60
75
default : {
@@ -67,7 +82,7 @@ export function defineCloudflareConfig(config: CloudflareOverrides = {}): OpenNe
67
82
queue : resolveQueue ( queue ) ,
68
83
cdnInvalidation : resolveCdnInvalidation ( cachePurge ) ,
69
84
} ,
70
- routePreloadingBehavior : "withWaitUntil" ,
85
+ routePreloadingBehavior,
71
86
} ,
72
87
// node:crypto is used to compute cache keys
73
88
edgeExternals : [ "node:crypto" ] ,
0 commit comments