diff --git a/docs/widgets/services/tdarr.md b/docs/widgets/services/tdarr.md index 763fc6268..3f201f053 100644 --- a/docs/widgets/services/tdarr.md +++ b/docs/widgets/services/tdarr.md @@ -11,4 +11,5 @@ Allowed fields: `["queue", "processed", "errored", "saved"]`. widget: type: tdarr url: http://tdarr.host.or.ip + key: tdarrapikey # optional, false if unused ``` diff --git a/src/widgets/tdarr/proxy.js b/src/widgets/tdarr/proxy.js index 898082f40..9e26fdc06 100644 --- a/src/widgets/tdarr/proxy.js +++ b/src/widgets/tdarr/proxy.js @@ -21,9 +21,13 @@ 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 = { + "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 +37,7 @@ export default async function tdarrProxyHandler(req, res) { docID: "statistics", }, }), - headers: { - "content-type": "application/json", - }, + headers, }); if (status !== 200) {