mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-12 07:58:49 +00:00
Merge branch 'main' into add-qbittorrent
This commit is contained in:
commit
6c01a85077
4 changed files with 45 additions and 3 deletions
|
@ -2,7 +2,7 @@ import getServiceWidget from "utils/service-helpers";
|
|||
import { formatApiCall } from "utils/api-helpers";
|
||||
import { httpProxy } from "utils/http";
|
||||
|
||||
export default async function genericProxyHandler(req, res) {
|
||||
export default async function genericProxyHandler(req, res, maps) {
|
||||
const { group, service, endpoint } = req.query;
|
||||
|
||||
if (group && service) {
|
||||
|
@ -23,13 +23,18 @@ export default async function genericProxyHandler(req, res) {
|
|||
headers,
|
||||
});
|
||||
|
||||
let resultData = data;
|
||||
if (maps?.[endpoint]) {
|
||||
resultData = maps[endpoint](data);
|
||||
}
|
||||
|
||||
if (contentType) res.setHeader("Content-Type", contentType);
|
||||
|
||||
if (status === 204 || status === 304) {
|
||||
return res.status(status).end();
|
||||
}
|
||||
|
||||
return res.status(status).send(data);
|
||||
return res.status(status).send(resultData);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue