Skip to content

Commit 722982f

Browse files
committed
check for meta tag router webpage reporting false offline
1 parent 0aa17a1 commit 722982f

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

backend/src/routes/health.route.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,29 @@ healthRoute.get('/', async (req: Request, res: Response): Promise<void> => {
1717
}
1818

1919
try {
20-
const response = await axios.get(url, { timeout: 5000, httpsAgent });
20+
const response = await axios.get(url, {
21+
timeout: 5000,
22+
httpsAgent,
23+
responseType: 'text'
24+
});
2125

22-
res.json({ status: response.status >= 100 && response.status < 400 ? 'online' : 'offline' });
26+
// Check if response is successful
27+
if (response.status >= 200 && response.status < 400) {
28+
// Check for meta refresh tags in HTML responses
29+
res.json({ status: 'online' });
30+
return;
31+
}
32+
33+
if (response.headers['content-type']?.includes('text/html') &&
34+
typeof response.data === 'string' &&
35+
(response.data.includes('<meta http-equiv="refresh"') ||
36+
response.data.includes('<meta http-equiv=\'refresh\'') ||
37+
response.data.includes('<meta http-equiv=refresh'))) {
38+
res.json({ status: 'online' });
39+
return;
40+
}
41+
42+
res.json({ status: 'offline' });
2343
} catch (error) {
2444
res.json({ status: 'offline' });
2545
}

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lab-dash-frontend",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"private": true,
55
"scripts": {
66
"dev": "vite --host",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lab-dash",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "This is an open-source user interface designed to manage your server and homelab",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)