fix: auth/me check on load
This commit is contained in:
parent
ea9fadb3e0
commit
c27a783388
|
|
@ -794,9 +794,22 @@ async function pollBuild(){
|
|||
return null
|
||||
}
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
// Sjekk auth-status
|
||||
try {
|
||||
const r = await fetch('/auth/me')
|
||||
if(r.ok){
|
||||
const u = await r.json()
|
||||
document.getElementById('sb-session').textContent = u.email || 'innlogget'
|
||||
document.getElementById('send-btn').disabled = false
|
||||
} else {
|
||||
window.location.href = '/auth/login'
|
||||
}
|
||||
} catch(e) {
|
||||
document.getElementById('sb-session').textContent = 'session: feil'
|
||||
}
|
||||
pollBuild()
|
||||
setInterval(pollBuild,30000)
|
||||
setInterval(pollBuild, 30000)
|
||||
})
|
||||
|
||||
// ─── Fix 3: CostGuard — fetchWithTimeout helper (AbortController, 10s) ───
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user