diff --git a/src/renderer/features/workspace/mappers.ts b/src/renderer/features/workspace/mappers.ts index 390c8c04..b1c802fa 100644 --- a/src/renderer/features/workspace/mappers.ts +++ b/src/renderer/features/workspace/mappers.ts @@ -39,8 +39,7 @@ export const mapToGlobalSettingsFormValues = (cfg: IWorkspaceCfg): GlobalSetting HTTPS_PROXY, IGNORE_CERT_ERRORS, } = cfg; - - const defaultApi = APIS && APIS[DEFAULT_API_INDEX] ? APIS[DEFAULT_API_INDEX] : null; + const defaultApi = APIS && DEFAULT_API_INDEX >= 0 && APIS[DEFAULT_API_INDEX] ? APIS[DEFAULT_API_INDEX] : null; const hasNoProxy = !HTTP_PROXY && !PAC_PROXY; const initialProxyMode = hasNoProxy ? ProxyMode.NoProxy : PAC_PROXY ? ProxyMode.Automatic : ProxyMode.Manual; @@ -52,9 +51,9 @@ export const mapToGlobalSettingsFormValues = (cfg: IWorkspaceCfg): GlobalSetting const sameConfigAsHttp = httpHost === httpsHost && httpPort === httpsPort; return { - apiKey: defaultApi.API_KEY, + apiKey: defaultApi?.API_KEY, apis: APIS || [], - apiUrl: defaultApi.URL, + apiUrl: defaultApi?.URL, language: LNG, sbomLedgerToken: TOKEN, proxyConfig: {