Merge pull request #1869 from rauenzi/widget-options

Allow widgets to add headers or set method
pull/1876/head
shamoon 1 year ago committed by GitHub
commit 43b32fd1fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -20,14 +20,14 @@ 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 }));
const headers = req.extraHeaders ?? {}; const headers = req.extraHeaders ?? widget.headers ?? {};
if (widget.username && widget.password) { if (widget.username && widget.password) {
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`; headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
} }
const params = { const params = {
method: req.method, method: widget.method ?? req.method,
headers, headers,
} }
if (req.body) { if (req.body) {

Loading…
Cancel
Save