mirror of
https://github.com/karl0ss/homepage.git
synced 2025-07-03 14:39:08 +01:00
Allow username + password for glances
This commit is contained in:
parent
802fe0f721
commit
99b70f96e4
@ -18,14 +18,22 @@ export default async function handler(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const apiUrl = `${url}/api/3/quicklook`;
|
const apiUrl = `${url}/api/3/quicklook`;
|
||||||
const params = { method: "GET", headers: {
|
const headers = {
|
||||||
"Accept-Encoding": "application/json"
|
"Accept-Encoding": "application/json"
|
||||||
} };
|
};
|
||||||
|
if (settings.username && settings.password) {
|
||||||
|
headers.Authorization = `Basic ${Buffer.from(`${settings.username}:${settings.password}`).toString("base64")}`
|
||||||
|
}
|
||||||
|
const params = { method: "GET", headers };
|
||||||
|
|
||||||
const [status, contentType, data] = await httpProxy(apiUrl, params);
|
const [status, contentType, data] = await httpProxy(apiUrl, params);
|
||||||
|
|
||||||
|
if (status === 401) {
|
||||||
|
logger.error("Authorization failure getting data from glances API. Data: %s", data);
|
||||||
|
}
|
||||||
|
|
||||||
if (status !== 200) {
|
if (status !== 200) {
|
||||||
logger.error("HTTP %d getting data from glances API %s. Data: %s", status, apiUrl, data);
|
logger.error("HTTP %d getting data from glances API. Data: %s", status, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contentType) res.setHeader("Content-Type", contentType);
|
if (contentType) res.setHeader("Content-Type", contentType);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user