File tree Expand file tree Collapse file tree 5 files changed +195
-23
lines changed Expand file tree Collapse file tree 5 files changed +195
-23
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
+ import { getDeploymentId } from '@opennextjs/cloudflare' ;
2
3
import createNextIntlPlugin from 'next-intl/plugin' ;
3
4
4
5
import { BASE_PATH , ENABLE_STATIC_EXPORT } from './next.constants.mjs' ;
@@ -95,6 +96,9 @@ const nextConfig = {
95
96
'shiki' ,
96
97
] ,
97
98
} ,
99
+ // If we're building for the Cloudflare deployment we want to set
100
+ // an appropriate deploymentId (needed for skew protection)
101
+ deploymentId : process . env . CLOUDFLARE ? getDeploymentId ( ) : undefined ,
98
102
} ;
99
103
100
104
const withNextIntl = createNextIntlPlugin ( './i18n.tsx' ) ;
Original file line number Diff line number Diff line change
1
+ import type { OpenNextConfig } from '@opennextjs/cloudflare' ;
1
2
import { defineCloudflareConfig } from '@opennextjs/cloudflare' ;
2
3
import incrementalCache from '@opennextjs/cloudflare/overrides/incremental-cache/kv-incremental-cache' ;
3
4
4
5
const cloudflareConfig = defineCloudflareConfig ( { incrementalCache } ) ;
5
6
6
- export default { ...cloudflareConfig , buildCommand : 'pnpm build:default' } ;
7
+ const openNextConfig : OpenNextConfig = {
8
+ ...cloudflareConfig ,
9
+ buildCommand : 'pnpm build:default' ,
10
+ cloudflare : {
11
+ skewProtection : {
12
+ enabled : true ,
13
+ } ,
14
+ } ,
15
+ } ;
16
+
17
+ export default openNextConfig ;
Original file line number Diff line number Diff line change 7
7
"build:blog-data" : " cross-env NODE_NO_WARNINGS=1 node ./scripts/blog-data/generate.mjs" ,
8
8
"build:blog-data:watch" : " node --watch --watch-path=pages/en/blog ./scripts/blog-data/generate.mjs" ,
9
9
"build:default" : " cross-env NODE_NO_WARNINGS=1 next build" ,
10
- "cloudflare:build:worker" : " opennextjs-cloudflare build" ,
10
+ "cloudflare:build:worker" : " CLOUDFLARE=true opennextjs-cloudflare build" ,
11
11
"cloudflare:deploy" : " wrangler deploy" ,
12
12
"cloudflare:preview" : " wrangler dev" ,
13
13
"predeploy" : " node --run build:blog-data" ,
80
80
"@eslint/eslintrc" : " ~3.3.1" ,
81
81
"@flarelabs-net/wrangler-build-time-fs-assets-polyfilling" : " ^0.0.0" ,
82
82
"@next/eslint-plugin-next" : " 15.3.4" ,
83
- "@opennextjs/cloudflare" : " ^1.3.0 " ,
83
+ "@opennextjs/cloudflare" : " ^1.5.1 " ,
84
84
"@playwright/test" : " ^1.53.2" ,
85
85
"@testing-library/user-event" : " ~14.6.1" ,
86
86
"@types/semver" : " ~7.7.0" ,
Original file line number Diff line number Diff line change 1
1
{
2
+ "$schema" : " ./node_modules/wrangler/config-schema.json" ,
2
3
"main" : " .open-next/worker.js" ,
3
4
"name" : " nodejs-website" ,
4
5
"compatibility_date" : " 2024-11-07" ,
9
10
"assets" : {
10
11
"directory" : " .open-next/assets" ,
11
12
"binding" : " ASSETS" ,
13
+ "run_worker_first" : true ,
14
+ },
15
+ "vars" : {
16
+ // Variables needed for skew protection
17
+ // Also not that an appropriate CF_WORKERS_SCRIPTS_API_TOKEN secret
18
+ // needs to be set as well in the Cloudflare dashboard
19
+ "CF_WORKER_NAME" : " nodejs-website" ,
20
+ "CF_PREVIEW_DOMAIN" : " testing.devprod.cloudflare.dev" ,
21
+ "CF_ACCOUNT_ID" : " 8ed4d03ac99f77561d0e8c9cbcc76cb6" ,
12
22
},
13
23
"observability" : {
14
24
"enabled" : true ,
You can’t perform that action at this time.
0 commit comments