fix(cli): always update server_url on login

Previously, `multica login` only saved server_url to config when it was
empty. A stale value (e.g. from a prior session pointing at a different
host) was never overwritten, causing subsequent API calls to hit the
wrong server.
This commit is contained in:
Jiayuan 2026-03-30 01:49:07 +08:00
parent a10515fa74
commit c3a9190016

View file

@ -202,9 +202,7 @@ func runAuthLoginBrowser(cmd *cobra.Command) error {
// Save to config.
cfg, _ := cli.LoadCLIConfig()
cfg.Token = patResp.Token
if cfg.ServerURL == "" {
cfg.ServerURL = serverURL
}
cfg.ServerURL = serverURL
if err := cli.SaveCLIConfig(cfg); err != nil {
return fmt.Errorf("failed to save config: %w", err)
}
@ -243,9 +241,7 @@ func runAuthLoginToken(cmd *cobra.Command) error {
cfg, _ := cli.LoadCLIConfig()
cfg.Token = token
if cfg.ServerURL == "" {
cfg.ServerURL = serverURL
}
cfg.ServerURL = serverURL
if err := cli.SaveCLIConfig(cfg); err != nil {
return fmt.Errorf("failed to save config: %w", err)
}