Skip to content

Commit 945f849

Browse files
move logic inside getDeploymentMapping
1 parent 3624660 commit 945f849

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

packages/cloudflare/src/cli/commands/deploy.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ export async function deployCommand(args: WithWranglerArgs<{ cacheChunkSize: num
2727

2828
const wranglerConfig = readWranglerConfig(args);
2929

30-
const platformProxyEnvVars = await getEnvFromPlatformProxy({
30+
const envVars = await getEnvFromPlatformProxy({
3131
configPath: args.configPath,
3232
environment: args.env,
3333
});
3434

35-
const envVars = { ...platformProxyEnvVars, ...process.env };
36-
3735
const deploymentMapping = await getDeploymentMapping(options, config, envVars);
3836

3937
await populateCache(options, config, wranglerConfig, {

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

packages/cloudflare/src/cli/commands/upload.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ export async function uploadCommand(args: WithWranglerArgs<{ cacheChunkSize: num
2727

2828
const wranglerConfig = readWranglerConfig(args);
2929

30-
const platformProxyEnvVars = await getEnvFromPlatformProxy({
30+
const envVars = await getEnvFromPlatformProxy({
3131
configPath: args.configPath,
3232
environment: args.env,
3333
});
3434

35-
const envVars = { ...platformProxyEnvVars, ...process.env };
36-
3735
const deploymentMapping = await getDeploymentMapping(options, config, envVars);
3836

3937
await populateCache(options, config, wranglerConfig, {

0 commit comments

Comments
 (0)