diff --git a/frontend/src/main.js b/frontend/src/main.js index 9c2dedf..1af24b6 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -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.'); + } + }); }); } diff --git a/src/config.rs b/src/config.rs index 5a1d6d6..b69a4c0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -15,7 +15,6 @@ pub struct Config { pub agent_max_turns: u32, pub agent_max_duration_secs: u64, pub vapid_private_key: String, - pub vapid_public_key: String, } impl Config { @@ -58,8 +57,6 @@ impl Config { let vapid_private_key = env::var("VAPID_PRIVATE_KEY") .map_err(|_| AppError::Config("VAPID_PRIVATE_KEY must be set".into()))?; - let vapid_public_key = env::var("VAPID_PUBLIC_KEY") - .map_err(|_| AppError::Config("VAPID_PUBLIC_KEY must be set".into()))?; Ok(Config { database_url, @@ -74,7 +71,6 @@ impl Config { agent_max_turns, agent_max_duration_secs, vapid_private_key, - vapid_public_key, }) } }