Skip to content

Commit e37f7ad

Browse files
committed
fix(webapp): prefer RUNTIME_API_ORIGIN over STREAM_ORIGIN for TRIGGER_STREAM_URL
Aligns precedence with the decoupling goal: when RUNTIME_API_ORIGIN is set (e.g. for cluster-internal runner traffic), it should override the external STREAM_ORIGIN too. Adds JSDoc on the two builtin resolvers explaining the precedence chain.
1 parent c1ee97e commit e37f7ad

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

apps/webapp/app/v3/environmentVariables/environmentVariablesRepository.server.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,14 @@ async function resolveOverridableTriggerVariables(
954954
return result;
955955
}
956956

957+
/**
958+
* Resolves built-in environment variables that are injected into dev (CLI) task
959+
* runs. `TRIGGER_API_URL` and `TRIGGER_STREAM_URL` prefer `RUNTIME_API_ORIGIN`
960+
* over `API_ORIGIN`/`STREAM_ORIGIN` so self-hosted deployments can keep
961+
* runner-to-webapp traffic on a cluster-internal hop (bypassing tracing-enabled
962+
* gateways that rewrite the W3C `traceparent` header on egress) without
963+
* affecting the public origins exposed to external clients.
964+
*/
957965
async function resolveBuiltInDevVariables(runtimeEnvironment: RuntimeEnvironmentForEnvRepo) {
958966
let result: Array<EnvironmentVariable> = [
959967
{
@@ -966,7 +974,7 @@ async function resolveBuiltInDevVariables(runtimeEnvironment: RuntimeEnvironment
966974
},
967975
{
968976
key: "TRIGGER_STREAM_URL",
969-
value: env.STREAM_ORIGIN ?? env.RUNTIME_API_ORIGIN ?? env.API_ORIGIN ?? env.APP_ORIGIN,
977+
value: env.RUNTIME_API_ORIGIN ?? env.STREAM_ORIGIN ?? env.API_ORIGIN ?? env.APP_ORIGIN,
970978
},
971979
];
972980

@@ -1093,6 +1101,15 @@ async function resolveOverridableOtelDevVariables(
10931101
return result;
10941102
}
10951103

1104+
/**
1105+
* Resolves built-in environment variables that are injected into managed
1106+
* (deployed) task runs. `TRIGGER_API_URL` and `TRIGGER_STREAM_URL` prefer
1107+
* `RUNTIME_API_ORIGIN` over `API_ORIGIN`/`STREAM_ORIGIN` so self-hosted
1108+
* deployments can keep runner-to-webapp traffic on a cluster-internal hop
1109+
* (bypassing tracing-enabled gateways that rewrite the W3C `traceparent`
1110+
* header on egress) without affecting the public origins exposed to external
1111+
* clients.
1112+
*/
10961113
async function resolveBuiltInProdVariables(
10971114
runtimeEnvironment: RuntimeEnvironmentForEnvRepo,
10981115
parentEnvironment?: RuntimeEnvironmentForEnvRepo
@@ -1108,7 +1125,7 @@ async function resolveBuiltInProdVariables(
11081125
},
11091126
{
11101127
key: "TRIGGER_STREAM_URL",
1111-
value: env.STREAM_ORIGIN ?? env.RUNTIME_API_ORIGIN ?? env.API_ORIGIN ?? env.APP_ORIGIN,
1128+
value: env.RUNTIME_API_ORIGIN ?? env.STREAM_ORIGIN ?? env.API_ORIGIN ?? env.APP_ORIGIN,
11121129
},
11131130
{
11141131
key: "TRIGGER_RUNTIME_WAIT_THRESHOLD_IN_MS",

0 commit comments

Comments
 (0)