mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-03 22:13:39 +01:00
Support extra headers in widgets
This commit is contained in:
parent
a234eeffb1
commit
7cede1318e
@ -55,6 +55,10 @@ export default async function handler(req, res) {
|
|||||||
req.query.endpoint = `${req.query.endpoint}?${query}`;
|
req.query.endpoint = `${req.query.endpoint}?${query}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mapping?.headers) {
|
||||||
|
req.extraHeaders = mapping.headers;
|
||||||
|
}
|
||||||
|
|
||||||
if (endpointProxy instanceof Function) {
|
if (endpointProxy instanceof Function) {
|
||||||
return endpointProxy(req, res, map);
|
return endpointProxy(req, res, map);
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,10 @@ export default async function genericProxyHandler(req, res, map) {
|
|||||||
if (widget) {
|
if (widget) {
|
||||||
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
|
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
|
||||||
|
|
||||||
let headers;
|
const headers = req.extraHeaders ?? {};
|
||||||
|
|
||||||
if (widget.username && widget.password) {
|
if (widget.username && widget.password) {
|
||||||
headers = {
|
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
|
||||||
Authorization: `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user