@@ -288,15 +288,30 @@ async function prepareGatewayStartupConfig(params: {
288288 tailscale : params . tailscaleOverride ,
289289 } ,
290290 ) ;
291- await params . activateRuntimeSecrets ( startupPreflightConfig , {
292- reason : "startup" ,
293- activate : false ,
294- } ) ;
291+ const preflightConfig = (
292+ await params . activateRuntimeSecrets ( startupPreflightConfig , {
293+ reason : "startup" ,
294+ activate : false ,
295+ } )
296+ ) . config ;
297+ const preflightAuthOverride =
298+ typeof preflightConfig . gateway ?. auth ?. token === "string" ||
299+ typeof preflightConfig . gateway ?. auth ?. password === "string"
300+ ? {
301+ ...params . authOverride ,
302+ ...( typeof preflightConfig . gateway ?. auth ?. token === "string"
303+ ? { token : preflightConfig . gateway . auth . token }
304+ : { } ) ,
305+ ...( typeof preflightConfig . gateway ?. auth ?. password === "string"
306+ ? { password : preflightConfig . gateway . auth . password }
307+ : { } ) ,
308+ }
309+ : params . authOverride ;
295310
296311 const authBootstrap = await ensureGatewayStartupAuth ( {
297312 cfg : params . runtimeConfig ,
298313 env : process . env ,
299- authOverride : params . authOverride ,
314+ authOverride : preflightAuthOverride ,
300315 tailscaleOverride : params . tailscaleOverride ,
301316 persist : true ,
302317 baseHash : params . configSnapshot . hash ,
@@ -637,7 +652,8 @@ export async function startGatewayServer(
637652 } = runtimeConfig ;
638653 const getResolvedAuth = ( ) =>
639654 resolveGatewayAuth ( {
640- authConfig : getRuntimeConfig ( ) . gateway ?. auth ,
655+ authConfig :
656+ getActiveSecretsRuntimeSnapshot ( ) ?. config . gateway ?. auth ?? getRuntimeConfig ( ) . gateway ?. auth ,
641657 authOverride : opts . auth ,
642658 env : process . env ,
643659 tailscaleMode,
0 commit comments