mirror of
https://github.com/benphelps/homepage.git
synced 2026-03-26 12:00:06 +01:00
24 lines
670 B
JavaScript
24 lines
670 B
JavaScript
import { httpProxy } from "utils/proxy/http";
|
|
|
|
export default async function handler(req, res) {
|
|
const { url } = req.query;
|
|
|
|
if (!url) {
|
|
return res.status(400).json({ error: "Missing Glances URL" });
|
|
}
|
|
|
|
const apiUrl = `${url}/api/3/quicklook`;
|
|
const params = { method: "GET", headers: {
|
|
"Accept-Encoding": "application/json"
|
|
} };
|
|
|
|
const [status, contentType, data, responseHeaders] = await httpProxy(apiUrl, params);
|
|
|
|
if (status !== 200) {
|
|
logger.error("HTTP %d getting data from glances API %s. Data: %s", status, apiUrl, data);
|
|
}
|
|
|
|
if (contentType) res.setHeader("Content-Type", contentType);
|
|
return res.status(status).send(data);
|
|
}
|