mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-09 14:58:47 +00:00
Add detailed Error component for service widgets
This commit is contained in:
parent
7b7740563e
commit
21017e4716
37 changed files with 113 additions and 113 deletions
|
@ -74,7 +74,7 @@ export default async function unifiProxyHandler(req, res) {
|
|||
// don't make two requests each time data from Unifi is required
|
||||
[status, contentType, data, responseHeaders] = await httpProxy(widget.url);
|
||||
prefix = "";
|
||||
if (responseHeaders["x-csrf-token"]) {
|
||||
if (responseHeaders?.["x-csrf-token"]) {
|
||||
prefix = udmpPrefix;
|
||||
}
|
||||
cache.put(prefixCacheKey, prefix);
|
||||
|
@ -88,13 +88,14 @@ export default async function unifiProxyHandler(req, res) {
|
|||
setCookieHeader(url, params);
|
||||
|
||||
[status, contentType, data, responseHeaders] = await httpProxy(url, params);
|
||||
|
||||
if (status === 401) {
|
||||
logger.debug("Unifi isn't logged in or rejected the reqeust, attempting login.");
|
||||
[status, contentType, data, responseHeaders] = await login(widget);
|
||||
|
||||
if (status !== 200) {
|
||||
logger.error("HTTP %d logging in to Unifi. Data: %s", status, data);
|
||||
return res.status(status).end(data);
|
||||
return res.status(status).json({error: {message: `HTTP Error ${status}`, url, data}});
|
||||
}
|
||||
|
||||
const json = JSON.parse(data.toString());
|
||||
|
@ -112,6 +113,7 @@ export default async function unifiProxyHandler(req, res) {
|
|||
|
||||
if (status !== 200) {
|
||||
logger.error("HTTP %d getting data from Unifi endpoint %s. Data: %s", status, url.href, data);
|
||||
return res.status(status).json({error: {message: `HTTP Error ${status}`, url, data}});
|
||||
}
|
||||
|
||||
if (contentType) res.setHeader("Content-Type", contentType);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue