diff --git a/electron/utils/device-oauth.ts b/electron/utils/device-oauth.ts index e4a4c407a..213be03ae 100644 --- a/electron/utils/device-oauth.ts +++ b/electron/utils/device-oauth.ts @@ -223,9 +223,19 @@ class DeviceOAuthManager extends EventEmitter { let baseUrl = token.resourceUrl || defaultBaseUrl; + // Ensure baseUrl has a protocol prefix + if (baseUrl && !baseUrl.startsWith('http://') && !baseUrl.startsWith('https://')) { + baseUrl = 'https://' + baseUrl; + } + // Ensure the base URL ends with /anthropic if (providerType.startsWith('minimax-portal') && baseUrl) { baseUrl = baseUrl.replace(/\/v1$/, '').replace(/\/anthropic$/, '').replace(/\/$/, '') + '/anthropic'; + } else if (providerType === 'qwen-portal' && baseUrl) { + // Ensure Qwen API gets /v1 at the end + if (!baseUrl.endsWith('/v1')) { + baseUrl = baseUrl.replace(/\/$/, '') + '/v1'; + } } try {