parent
91db5861c8
commit
8d19873738
2 changed files with 14 additions and 6 deletions
|
|
@ -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.');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue