Skip to content

Commit be6a492

Browse files
fix deploy and upload commands not taking into account environment variables (#818)
1 parent 3de7962 commit be6a492

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.changeset/legal-bags-agree.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
fix `deploy` and `upload` commands not taking into account environment variables

packages/cloudflare/src/cli/commands/skew-protection.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,23 @@ const MS_PER_DAY = 24 * 3600 * 1000;
4545
*
4646
* @param options Build options
4747
* @param config OpenNext config
48-
* @param envVars Environment variables
48+
* @param workerEnvVars Worker Environment variables (taken from the wrangler config files)
4949
* @returns Deployment mapping or undefined
5050
*/
5151
export async function getDeploymentMapping(
5252
options: BuildOptions,
5353
config: OpenNextConfig,
54-
envVars: WorkerEnvVar
54+
workerEnvVars: WorkerEnvVar
5555
): Promise<Record<string, string> | undefined> {
5656
if (config.cloudflare?.skewProtection?.enabled !== true) {
5757
return undefined;
5858
}
5959

60+
// Note that `process.env` is spread after `workerEnvVars` since we do want
61+
// system environment variables to take precedence over the variables defined
62+
// in the wrangler config files
63+
const envVars = { ...workerEnvVars, ...process.env };
64+
6065
const nextConfig = loadConfig(path.join(options.appBuildOutputPath, ".next"));
6166
const deploymentId = nextConfig.deploymentId;
6267

0 commit comments

Comments
 (0)