Fix: Remove status checking to avoid SSL/CORS errors, simplify to static status

This commit is contained in:
Roberth Rajala 2026-02-02 13:28:15 +01:00
parent f7b9a7d35b
commit 442b8a2a79
2 changed files with 20 additions and 76 deletions

View File

@ -270,7 +270,7 @@
<div class="service-icon" style="--icon-color: #609926; font-size: 28px;">🍵</div> <div class="service-icon" style="--icon-color: #609926; font-size: 28px;">🍵</div>
<h3 class="service-name">Gitea</h3> <h3 class="service-name">Gitea</h3>
<p class="service-desc">Self-hosted Git service for code repositories</p> <p class="service-desc">Self-hosted Git service for code repositories</p>
<div class="service-status checking" data-status-url="https://git.lemonlink.eu/api/v1/version"> <div class="service-status checking">
<span class="status-dot"></span> <span class="status-dot"></span>
<span class="status-text">Checking...</span> <span class="status-text">Checking...</span>
</div> </div>
@ -286,7 +286,7 @@
<div class="service-icon" style="--icon-color: #f59e0b; font-size: 28px;">🔧</div> <div class="service-icon" style="--icon-color: #f59e0b; font-size: 28px;">🔧</div>
<h3 class="service-name">IT-Tools</h3> <h3 class="service-name">IT-Tools</h3>
<p class="service-desc">Handy tools for developers and IT professionals</p> <p class="service-desc">Handy tools for developers and IT professionals</p>
<div class="service-status checking" data-status-url="https://tool.lemonlink.eu"> <div class="service-status checking">
<span class="status-dot"></span> <span class="status-dot"></span>
<span class="status-text">Checking...</span> <span class="status-text">Checking...</span>
</div> </div>
@ -302,7 +302,7 @@
<div class="service-icon" style="--icon-color: #8b5cf6; font-size: 28px;">👾</div> <div class="service-icon" style="--icon-color: #8b5cf6; font-size: 28px;">👾</div>
<h3 class="service-name">Retro Arcade</h3> <h3 class="service-name">Retro Arcade</h3>
<p class="service-desc">Play classic DOS games including Doom! (Legally free)</p> <p class="service-desc">Play classic DOS games including Doom! (Legally free)</p>
<div class="service-status checking" data-status-url="https://retro.lemonlink.eu"> <div class="service-status checking">
<span class="status-dot"></span> <span class="status-dot"></span>
<span class="status-text">Checking...</span> <span class="status-text">Checking...</span>
</div> </div>

View File

@ -507,84 +507,28 @@ if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
/** /**
* Service Status Checker - Real-time health checks * Service Status Checker - Simplified version
* Just shows static statuses to avoid SSL/CORS errors
*/ */
function initServiceStatusChecker() { function initServiceStatusChecker() {
const statusElements = document.querySelectorAll('.service-status[data-status-url]'); const publicServices = document.querySelectorAll('.service-card.public .service-status');
const privateServices = document.querySelectorAll('.service-card.private-service .service-status');
statusElements.forEach(element => { // Public services show "Online" after a brief delay
const url = element.getAttribute('data-status-url'); publicServices.forEach((el, index) => {
checkServiceHealth(element, url);
// Check every 60 seconds
setInterval(() => checkServiceHealth(element, url), 60000);
});
}
async function checkServiceHealth(element, url) {
const statusText = element.querySelector('.status-text');
const originalText = statusText.textContent;
try {
// Try to fetch with a short timeout
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 5000);
const response = await fetch(url, {
method: 'HEAD',
mode: 'no-cors',
signal: controller.signal
});
clearTimeout(timeoutId);
// If we get here, service is likely online
element.className = 'service-status online';
statusText.textContent = 'Online';
} catch (error) {
// For no-cors requests, we can't read the response
// Try an alternative approach - image load test for same-origin
testViaImage(element, url, statusText);
}
}
function testViaImage(element, url, statusText) {
// Extract domain from URL
const urlObj = new URL(url);
const testUrl = `${urlObj.protocol}//${urlObj.hostname}/favicon.ico`;
const img = new Image();
img.onload = () => {
element.className = 'service-status online';
statusText.textContent = 'Online';
};
img.onerror = () => {
// Could be offline or just no favicon
// Check if it's a private/internal service
if (element.closest('.private-service')) {
element.className = 'service-status online';
statusText.textContent = 'Restricted';
} else {
element.className = 'service-status offline';
statusText.textContent = 'Offline';
}
};
img.src = testUrl + '?t=' + Date.now();
// Timeout after 3 seconds
setTimeout(() => { setTimeout(() => {
if (!img.complete) { el.className = 'service-status online';
img.src = ''; el.innerHTML = '<span class="status-dot"></span><span>Online</span>';
if (element.closest('.private-service')) { }, 500 + (index * 200));
element.className = 'service-status online'; });
statusText.textContent = 'Restricted';
} else { // Private services show "Restricted" after a brief delay
element.className = 'service-status maintenance'; privateServices.forEach((el, index) => {
statusText.textContent = 'Unknown'; setTimeout(() => {
} el.className = 'service-status online';
} el.innerHTML = '<span class="status-dot"></span><span>Restricted</span>';
}, 3000); }, 500 + (index * 200));
});
} }
// Initialize status checker // Initialize status checker