Refuse a TRUST_PROXY the apps can't start with; Accounts reads loopback
A server configuration with TRUST_PROXY=TRUE made an Events install build for minutes, then fail: Express threw "invalid IP address: TRUE" at startup. - scripts/lib/envtpl.cjs: VALUE_RULES checked before any .env is written (exit 4, naming the value and the fix), for every release. - Contracts 1.6.0: agent.checkEnvValue / agent.invalidValues, the same rules for the Hub. - Accounts 1.0.1: TRUST_PROXY read as Events reads it; loopback used to turn proxy trust off. - Docs: CHANGELOGs, WHATS-NEW, HANDOVER, AGENT-1.0-PLAN, ROLLOUT-1.0, READMEs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -54,6 +54,33 @@ envtpl() { node "$TPL_JS" --template "$TMP/template.json" --dir "$APP" --product
|
||||
[ ! -e "$APP/frontend/.env.production" ]
|
||||
}
|
||||
|
||||
@test "a value the app can't start with: nothing is written, the value and the fix are named" {
|
||||
printf '{ "server": { "TRUST_PROXY": "TRUE" } }\n' > "$TMP/bad.json"
|
||||
run envtpl --config "$TMP/bad.json" --release events@2.4.0
|
||||
[ "$status" -eq 4 ]
|
||||
[[ "$output" == *'TRUST_PROXY="TRUE" won'"'"'t work'* ]]
|
||||
[[ "$output" == *"loopback behind frp"* ]]
|
||||
[[ "$output" == *"server's configuration on the Hub"* ]]
|
||||
[ ! -e "$APP/backend/.env" ]
|
||||
[ ! -e "$APP/frontend/.env.production" ]
|
||||
}
|
||||
|
||||
@test "TRUST_PROXY: the values Events understands are accepted" {
|
||||
for v in loopback 1 true false 'loopback, 203.0.113.10' 10.0.0.0/8 '::1'; do
|
||||
rm -rf "$APP/backend/.env" "$APP/frontend/.env.production"
|
||||
printf '{ "server": { "TRUST_PROXY": "%s" } }\n' "$v" > "$TMP/ok.json"
|
||||
run envtpl --config "$TMP/ok.json"
|
||||
[ "$status" -eq 0 ] || { echo "$v: $output"; false; }
|
||||
done
|
||||
}
|
||||
|
||||
@test "deploy: a bad value already in a .env is left alone (only new variables are checked)" {
|
||||
printf 'DATABASE_URL=x\nPORT=1\nFRONTEND_URL=y\nTRUST_PROXY=TRUE\n' > "$APP/backend/.env"
|
||||
printf '{ "server": { "TRUST_PROXY": "TRUE" } }\n' > "$TMP/bad.json"
|
||||
run envtpl --config "$TMP/bad.json"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "--fallback fills a value no layer gives" {
|
||||
run envtpl --fallback TRUST_PROXY=1
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
Reference in New Issue
Block a user