From e556c90639ddb57dff4704185bb2921a2563568b Mon Sep 17 00:00:00 2001 From: wtfitsaduck Date: Wed, 4 Sep 2024 04:55:06 +0000 Subject: [PATCH] Add Tdarr Auth option --- src/widgets/tdarr/proxy.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/widgets/tdarr/proxy.js b/src/widgets/tdarr/proxy.js index 898082f40..0ba263490 100644 --- a/src/widgets/tdarr/proxy.js +++ b/src/widgets/tdarr/proxy.js @@ -21,9 +21,12 @@ export default async function tdarrProxyHandler(req, res) { logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group); return res.status(400).json({ error: "Invalid proxy service type" }); } - + const headers = {} + headers["content-type"] = "application/json" + if (widget.key) { + headers["x-api-key"] = `${widget.key}`; + } const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint: undefined, ...widget })); - const [status, contentType, data] = await httpProxy(url, { method: "POST", body: JSON.stringify({ @@ -33,9 +36,7 @@ export default async function tdarrProxyHandler(req, res) { docID: "statistics", }, }), - headers: { - "content-type": "application/json", - }, + headers: headers }); if (status !== 200) {