mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-20 13:16:19 +01:00
Enhancement: support Tdarr widget auth (#3940)
--------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
parent
5de0019b3d
commit
989039af81
@ -11,4 +11,5 @@ Allowed fields: `["queue", "processed", "errored", "saved"]`.
|
|||||||
widget:
|
widget:
|
||||||
type: tdarr
|
type: tdarr
|
||||||
url: http://tdarr.host.or.ip
|
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);
|
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
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 url = new URL(formatApiCall(widgets[widget.type].api, { endpoint: undefined, ...widget }));
|
||||||
|
|
||||||
const [status, contentType, data] = await httpProxy(url, {
|
const [status, contentType, data] = await httpProxy(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@ -33,9 +37,7 @@ export default async function tdarrProxyHandler(req, res) {
|
|||||||
docID: "statistics",
|
docID: "statistics",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
headers: {
|
headers,
|
||||||
"content-type": "application/json",
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (status !== 200) {
|
if (status !== 200) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user