allow HTTP basic auth on generic proxy

pull/183/head
Ben Phelps 2 years ago
parent f14a811ce9
commit 578b715a1f

@ -10,8 +10,17 @@ export default async function genericProxyHandler(req, res) {
if (widget) { if (widget) {
const url = new URL(formatApiCall(widget.type, { endpoint, ...widget })); const url = new URL(formatApiCall(widget.type, { endpoint, ...widget }));
let headers;
if (widget.username && widget.password) {
headers = {
Authorization: `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`,
};
}
const [status, contentType, data] = await httpProxy(url, { const [status, contentType, data] = await httpProxy(url, {
method: req.method, method: req.method,
headers,
}); });
if (contentType) res.setHeader("Content-Type", contentType); if (contentType) res.setHeader("Content-Type", contentType);

Loading…
Cancel
Save