From 9dfa7ca93610852513d9f8217adc56dd4c993566 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 11 Jun 2026 12:38:40 +0200 Subject: [PATCH] Restore VOIP popup by allowing cookie-auth websocket fallback --- app/shared/frontend/base.html | 2 +- static/js/telefoni.js | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/shared/frontend/base.html b/app/shared/frontend/base.html index cb2b0c7..fc1d4f2 100644 --- a/app/shared/frontend/base.html +++ b/app/shared/frontend/base.html @@ -1267,7 +1267,7 @@ window.addEventListener('unhandledrejection', function(event) { - + diff --git a/static/js/telefoni.js b/static/js/telefoni.js index 4a5c21f..90b303d 100644 --- a/static/js/telefoni.js +++ b/static/js/telefoni.js @@ -226,18 +226,16 @@ } function connect() { - if (ws && ws.readyState === WebSocket.OPEN) { + if (ws && (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING)) { return; } const token = getToken(); - if (!token) { - scheduleReconnect(); - return; - } - const proto = window.location.protocol === 'https:' ? 'wss' : 'ws'; - const url = `${proto}://${window.location.host}/api/v1/telefoni/ws?token=${encodeURIComponent(token)}`; + // Fallback to cookie-auth websocket when token is HttpOnly and cannot be read by JS. + const url = token + ? `${proto}://${window.location.host}/api/v1/telefoni/ws?token=${encodeURIComponent(token)}` + : `${proto}://${window.location.host}/api/v1/telefoni/ws`; ws = new WebSocket(url); ws.onopen = () => console.log('📞 Telefoni WS connected');