Enhancement: support Tdarr widget auth (#3940)

---------

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
pull/3954/head
Wtfitsaduck 2 months ago committed by GitHub
parent 5de0019b3d
commit 989039af81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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
```

@ -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) {

Loading…
Cancel
Save