Skip to content

Commit a259564

Browse files
define OPEN_NEXT_CLOUDFLARE variable in next.consstants.mjs
1 parent 65b4b4b commit a259564

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

apps/site/next.config.mjs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
'use strict';
22
import createNextIntlPlugin from 'next-intl/plugin';
33

4-
import { BASE_PATH, ENABLE_STATIC_EXPORT } from './next.constants.mjs';
4+
import {
5+
BASE_PATH,
6+
ENABLE_STATIC_EXPORT,
7+
OPEN_NEXT_CLOUDFLARE,
8+
} from './next.constants.mjs';
59
import { redirects, rewrites } from './next.rewrites.mjs';
610

711
/** @type {import('next').NextConfig} */
@@ -20,12 +24,7 @@ const nextConfig = {
2024
// (https://developers.cloudflare.com/images/transform-images/sources/)
2125
// in the Cloudflare dashboard itself instead (to the exact same values present in `remotePatterns` below).
2226
//
23-
// TODO: The `OPEN_NEXT_CLOUDFLARE` environment variable is being
24-
// defined in the worker building script, ideally the open-next
25-
// adapter should set it itself when it invokes the Next.js build
26-
// process, once it does that remove the manual `OPEN_NEXT_CLOUDFLARE`
27-
// definition in the package.json script.
28-
process.env.OPEN_NEXT_CLOUDFLARE
27+
OPEN_NEXT_CLOUDFLARE
2928
? {
3029
loader: 'custom',
3130
loaderFile: './cloudflare-image-loader.ts',
@@ -125,12 +124,7 @@ const nextConfig = {
125124
},
126125
// If we're building for the Cloudflare deployment we want to set
127126
// an appropriate deploymentId (needed for skew protection)
128-
// TODO: The `OPEN_NEXT_CLOUDFLARE` environment variable is being
129-
// defined in the worker building script, ideally the open-next
130-
// adapter should set it itself when it invokes the Next.js build
131-
// process, once it does that remove the manual `OPEN_NEXT_CLOUDFLARE`
132-
// definition in the package.json script.
133-
deploymentId: process.env.OPEN_NEXT_CLOUDFLARE
127+
deploymentId: OPEN_NEXT_CLOUDFLARE
134128
? (await import('@opennextjs/cloudflare')).getDeploymentId()
135129
: undefined,
136130
};

apps/site/next.constants.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,14 @@ export const EOL_VERSION_IDENTIFIER = 'End-of-life';
193193
*/
194194
export const VULNERABILITIES_URL =
195195
'https://raw.githubusercontent.com/nodejs/security-wg/main/vuln/core/index.json';
196+
197+
/**
198+
* Whether the build process is targeting the Cloudflare open-next build or not.
199+
*
200+
* TODO: The `OPEN_NEXT_CLOUDFLARE` environment variable is being
201+
* defined in the worker building script, ideally the open-next
202+
* adapter should set it itself when it invokes the Next.js build
203+
* process, once it does that remove the manual `OPEN_NEXT_CLOUDFLARE`
204+
* definition in the package.json script.
205+
*/
206+
export const OPEN_NEXT_CLOUDFLARE = process.env.OPEN_NEXT_CLOUDFLARE;

0 commit comments

Comments
 (0)