push
All checks were successful
/ upload (release) Successful in 31s

This commit is contained in:
pavel 2026-02-12 01:34:24 +01:00
commit 8d19873738
2 changed files with 14 additions and 6 deletions

View file

@ -742,7 +742,14 @@ async function handleCallback() {
const response = await fetch(`${API_URL}/auth/callback?code=${code}&redirect_uri=${encodeURIComponent(AUTH_CONFIG.redirectUri)}`, {
credentials: 'include'
});
const data = await response.json();
const contentType = response.headers.get("content-type");
let data;
if (contentType && contentType.includes("application/json")) {
data = await response.json();
} else {
const text = await response.text();
throw new Error(`Expected JSON but got ${contentType}. Body: ${text.substring(0, 100)}`);
}
if (response.ok) {
state.isAuthenticated = true;
@ -820,7 +827,12 @@ if ('serviceWorker' in navigator) {
console.log('SW registered', reg);
setupPush(reg);
})
.catch(err => console.error('SW registration failed', err));
.catch(err => {
console.error('SW registration failed:', err);
if (window.isSecureContext === false) {
console.error('Context is NOT secure. Service Workers require HTTPS or localhost.');
}
});
});
}