Enhancement: Better handle some beszel errors (#4493)

This commit is contained in:
shamoon 2024-12-25 12:17:10 -08:00 committed by GitHub
parent cc9b4782f2
commit fd05ae377c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 8 deletions

View file

@ -59,7 +59,7 @@ export default async function beszelProxyHandler(req, res) {
if (!token) {
[status, token] = await login(loginUrl, widget.username, widget.password, service);
if (status !== 200) {
logger.debug(`HTTP ${status} logging into Beszel: ${token}`);
logger.debug(`HTTP ${status} logging into Beszel: ${JSON.stringify(token)}`);
return res.status(status).send(token);
}
}
@ -72,13 +72,13 @@ export default async function beszelProxyHandler(req, res) {
},
});
if (status === 403) {
if ([400, 403].includes(status)) {
logger.debug(`HTTP ${status} retrieving data from Beszel, logging in and trying again.`);
cache.del(`${tokenCacheKey}.${service}`);
[status, token] = await login(loginUrl, widget.username, widget.password, service);
if (status !== 200) {
logger.debug(`HTTP ${status} logging into Beszel: ${data}`);
logger.debug(`HTTP ${status} logging into Beszel: ${JSON.stringify(data)}`);
return res.status(status).send(data);
}