Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/legal-bags-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/cloudflare": patch
---

fix `deploy` and `upload` commands not taking into account environment variables
9 changes: 7 additions & 2 deletions packages/cloudflare/src/cli/commands/skew-protection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,23 @@ const MS_PER_DAY = 24 * 3600 * 1000;
*
* @param options Build options
* @param config OpenNext config
* @param envVars Environment variables
* @param workerEnvVars Worker Environment variables (taken from the wrangler config files)
* @returns Deployment mapping or undefined
*/
export async function getDeploymentMapping(
options: BuildOptions,
config: OpenNextConfig,
envVars: WorkerEnvVar
workerEnvVars: WorkerEnvVar
): Promise<Record<string, string> | undefined> {
if (config.cloudflare?.skewProtection?.enabled !== true) {
return undefined;
}

// Note that `process.env` is spread after `workerEnvVars` since we do want
// system environment variables to take precedence over the variables defined
// in the wrangler config files
const envVars = { ...workerEnvVars, ...process.env };

const nextConfig = loadConfig(path.join(options.appBuildOutputPath, ".next"));
const deploymentId = nextConfig.deploymentId;

Expand Down