diff --git a/lib/hosters.js b/lib/hosters.js index 80e2b49..367e857 100644 --- a/lib/hosters.js +++ b/lib/hosters.js @@ -281,7 +281,13 @@ async function apiGet(url, signal) { signal: controller.signal, redirect: 'follow' }); - const data = await res.json(); + let data; + try { + data = await res.json(); + } catch { + const text = await res.text().catch(() => ''); + throw new Error(`API-Antwort war kein JSON (HTTP ${res.status}): ${(text || '').slice(0, 200)}`); + } if (data.status && [401, 403, 429, 500].includes(data.status)) { throw new Error(data.msg || data.message || JSON.stringify(data)); @@ -300,7 +306,7 @@ async function getUploadServer(hosterName, hosterConfig, apiKey, signal) { for (let attempt = 1; attempt <= SERVER_RETRY_ATTEMPTS; attempt++) { for (const endpoint of hosterConfig.serverEndpoints) { - const url = `${hosterConfig.apiBase}${endpoint}?key=${apiKey}`; + const url = `${hosterConfig.apiBase}${endpoint}?key=${encodeURIComponent(apiKey)}`; try { const data = await apiGet(url, signal); const uploadUrl = extractUploadServerUrl(data, hosterConfig.apiBase);