Skip to content

Commit da37bfe

Browse files
committed
fix: stop merging build-env into wrangler runtime vars
build-env should only set shell environment variables during the build step, not be injected as Cloudflare Worker vars at runtime. Build-only values like NITRO_PRESET and NODE_OPTIONS were leaking into the worker environment, and conversely runtime secrets placed in build-env weren't being set as proper Worker secrets.
1 parent 438435c commit da37bfe

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

action.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ runs:
339339
echo "Merging $ENV_FILE into $NITRO_CONFIG..."
340340
341341
# Pass file paths via environment variables to avoid escaping issues
342-
NITRO_CONFIG="$NITRO_CONFIG" ENV_FILE="$ENV_FILE" BUILD_ENV='${{ inputs.build-env }}' node --eval '
342+
NITRO_CONFIG="$NITRO_CONFIG" ENV_FILE="$ENV_FILE" node --eval '
343343
const fs = require("fs");
344344
345345
// Strip JSONC comments (handles strings correctly to not break URLs)
@@ -424,7 +424,6 @@ runs:
424424
425425
const nitroConfigPath = process.env.NITRO_CONFIG;
426426
const envFilePath = process.env.ENV_FILE;
427-
const buildEnvJson = process.env.BUILD_ENV || "{}";
428427
429428
// Read Nuxt-generated config (has main, assets, etc.)
430429
const rawNitro = fs.readFileSync(nitroConfigPath, "utf8");
@@ -435,12 +434,6 @@ runs:
435434
const cleanedEnv = stripJsonComments(rawEnv).replace(/,\s*([}\]])/g, "$1");
436435
const envConfig = JSON.parse(cleanedEnv);
437436
438-
// Parse build-env and add as base vars (wrangler env vars take precedence)
439-
const buildEnv = JSON.parse(buildEnvJson.replace(/,\s*([}\]])/g, "$1"));
440-
if (Object.keys(buildEnv).length > 0) {
441-
envConfig.vars = { ...buildEnv, ...(envConfig.vars || {}) };
442-
}
443-
444437
// Merge: Nitro config + environment overrides
445438
const merged = deepMerge(nitroConfig, envConfig);
446439

0 commit comments

Comments
 (0)