diff --git a/src/views/LoginView.vue b/src/views/LoginView.vue index b553072..818db32 100644 --- a/src/views/LoginView.vue +++ b/src/views/LoginView.vue @@ -143,21 +143,27 @@ const customUrl = ref('') const selectedUrl = ref('') function initSelectedServer() { + // Reset api_key from env defaults to clear any stale key + localStorage.removeItem('portal_config') const config = getCurrentConfig() const currentUrl = config.api_base_url const matched = serverPresets.find(s => s.url === currentUrl) if (matched) { selectedUrl.value = matched.url showCustomUrl.value = false + saveConfig({ ...config, api_base_url: matched.url }) } else { selectedUrl.value = currentUrl customUrl.value = currentUrl showCustomUrl.value = true + saveConfig({ ...config }) } } function selectServer(srv: ServerPreset) { selectedUrl.value = srv.url + // Reset api_key from env to avoid using a stale key + localStorage.removeItem('portal_config') const config = getCurrentConfig() saveConfig({ ...config, api_base_url: srv.url }) } @@ -178,6 +184,8 @@ function toggleCustom() { function onCustomUrlInput() { selectedUrl.value = customUrl.value + // Reset api_key from env + localStorage.removeItem('portal_config') const config = getCurrentConfig() saveConfig({ ...config, api_base_url: customUrl.value }) } @@ -199,6 +207,7 @@ const handleLogin = async () => { let apiUrl = selectedUrl.value if (showCustomUrl.value && customUrl.value) { apiUrl = customUrl.value + localStorage.removeItem('portal_config') const config = getCurrentConfig() saveConfig({ ...config, api_base_url: customUrl.value }) }