diff --git a/server/routes/qbittorrent.ts b/server/routes/qbittorrent.ts index 9f95e33..ae5c284 100644 --- a/server/routes/qbittorrent.ts +++ b/server/routes/qbittorrent.ts @@ -14,11 +14,8 @@ async function getCookie(): Promise { const pass = process.env.QBT_PASSWORD if (!host || !user || !pass) throw new Error('QBT_HOST / QBT_USER / QBT_PASSWORD not configured') - const loginUrl = `${host}/api/v2/auth/login` - console.log(`[qbt] POST ${loginUrl} user=${user}`) - const res = await axios.post( - loginUrl, + `${host}/api/v2/auth/login`, new URLSearchParams({ username: user, password: pass }), { headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Referer': host, 'Origin': host }, @@ -26,9 +23,8 @@ async function getCookie(): Promise { } ) - console.log(`[qbt] status=${res.status} headers=${JSON.stringify(res.headers)} body=${JSON.stringify(res.data)}`) - - const cookie = (res.headers['set-cookie'] ?? []).find((c: string) => c.startsWith('SID=')) + // qBittorrent 5.x renamed the cookie from SID to QBT_SID_{port} + const cookie = (res.headers['set-cookie'] ?? []).find((c: string) => /^(QBT_)?SID[_=]/.test(c)) if (!cookie) throw new Error(`qBittorrent login failed (${res.status}): "${String(res.data).trim()}"`) sid = cookie.split(';')[0]