mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
fix qbittorrent widget
This commit is contained in:
parent
8e0075ff90
commit
616e56e3f5
@ -4,7 +4,8 @@ import { httpProxy } from "utils/proxy/http";
|
|||||||
import getServiceWidget from "utils/config/service-helpers";
|
import getServiceWidget from "utils/config/service-helpers";
|
||||||
|
|
||||||
async function login(widget, params) {
|
async function login(widget, params) {
|
||||||
const loginUrl = new URL(`${widget.url}/api/v2/auth/login`);
|
console.log("Doing login");
|
||||||
|
const loginUrl = new URL(`${widget.url}/api/v2/auth/login`).toString();
|
||||||
const loginBody = `username=${encodeURI(widget.username)}&password=${encodeURI(widget.password)}`;
|
const loginBody = `username=${encodeURI(widget.username)}&password=${encodeURI(widget.password)}`;
|
||||||
|
|
||||||
// using fetch intentionally, for login only, as the httpProxy method causes qBittorrent to
|
// using fetch intentionally, for login only, as the httpProxy method causes qBittorrent to
|
||||||
@ -36,8 +37,9 @@ export default async function qbittorrentProxyHandler(req, res) {
|
|||||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = new URL(formatApiCall(widget.type, { endpoint, ...widget }));
|
const url = new URL(formatApiCall("{url}/api/v2/{endpoint}", { endpoint, ...widget }));
|
||||||
const params = { method: "GET", headers: {} };
|
const params = { method: "GET", headers: {} };
|
||||||
|
|
||||||
setCookieHeader(url, params);
|
setCookieHeader(url, params);
|
||||||
|
|
||||||
if (!params.headers.Cookie) {
|
if (!params.headers.Cookie) {
|
||||||
@ -46,6 +48,7 @@ export default async function qbittorrentProxyHandler(req, res) {
|
|||||||
if (status !== 200) {
|
if (status !== 200) {
|
||||||
return res.status(status).end(data);
|
return res.status(status).end(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.toString() !== "Ok.") {
|
if (data.toString() !== "Ok.") {
|
||||||
return res.status(401).end(data);
|
return res.status(401).end(data);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import qbittorrentProxyHandler from "./proxy";
|
import qbittorrentProxyHandler from "./proxy";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/v2/{endpoint}",
|
|
||||||
proxyHandler: qbittorrentProxyHandler,
|
proxyHandler: qbittorrentProxyHandler,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user