@@ -13,7 +13,7 @@ import {
1313const CONSOLE_LOGIN_TIMEOUT_MS = 15 * 60 * 1000 ;
1414const MAX_AUTH_CALLBACK_BODY = 65536 ;
1515
16- const DEFAULT_CONSOLE_ORIGIN = "https://bailian.console.aliyun.com" ;
16+ const DEFAULT_CONSOLE_ORIGIN = "https://pre- bailian.console.aliyun.com" ;
1717
1818export function resolveConsoleOrigin ( ) : string {
1919 return process . env . BAILIAN_CONSOLE_ORIGIN || DEFAULT_CONSOLE_ORIGIN ;
@@ -323,38 +323,21 @@ export async function runConsoleLogin(
323323
324324 const { accessToken, apiKey, baseUrl, consoleSite, consoleRegion, consoleSwitchAgent } =
325325 await extractCredentialsFromRequest ( req ) ;
326+ const hasConfig =
327+ accessToken || baseUrl || consoleSite || consoleRegion || consoleSwitchAgent ;
326328
327- if ( accessToken || apiKey || baseUrl || consoleSite || consoleRegion || consoleSwitchAgent ) {
329+ if ( hasConfig || apiKey ) {
328330 try {
329- const existing = readConfigFile ( ) as Record < string , unknown > ;
330- let changed = false ;
331-
332- if ( accessToken ) {
333- existing . access_token = accessToken ;
334- changed = true ;
335- }
336- if ( baseUrl ) {
337- existing . base_url = baseUrl ;
338- changed = true ;
339- }
340- if ( consoleSite ) {
341- existing . console_site = consoleSite ;
342- changed = true ;
343- }
344- if ( consoleRegion ) {
345- existing . console_region = consoleRegion ;
346- changed = true ;
347- }
348- if ( consoleSwitchAgent ) {
349- existing . console_switch_agent = Number ( consoleSwitchAgent ) ;
350- changed = true ;
351- }
352-
353- if ( changed ) {
331+ if ( hasConfig ) {
332+ const existing = readConfigFile ( ) as Record < string , unknown > ;
333+ if ( accessToken ) existing . access_token = accessToken ;
334+ if ( baseUrl ) existing . base_url = baseUrl ;
335+ if ( consoleSite ) existing . console_site = consoleSite ;
336+ if ( consoleRegion ) existing . console_region = consoleRegion ;
337+ if ( consoleSwitchAgent ) existing . console_switch_agent = Number ( consoleSwitchAgent ) ;
354338 await writeConfigFile ( existing ) ;
355339 process . stderr . write ( `Config saved to ${ getConfigPath ( ) } \n` ) ;
356340 }
357-
358341 if ( apiKey && opts ?. onApiKey ) {
359342 await opts . onApiKey ( apiKey ) ;
360343 }
@@ -373,7 +356,7 @@ export async function runConsoleLogin(
373356 } ) ;
374357 res . end ( "OK\n" ) ;
375358
376- if ( accessToken || apiKey || baseUrl || consoleSite || consoleRegion || consoleSwitchAgent ) {
359+ if ( hasConfig || apiKey ) {
377360 server . close ( ) ;
378361 }
379362 } catch {
0 commit comments