From e91c919b46f69f77870192081cf6520ceaa61c7c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 22 Dec 2025 07:11:03 +0000 Subject: [PATCH] Refactor: Use query token for API video playback Co-authored-by: mathieumoran1 --- public/js/app_player.js | 14 ++++++-------- public/player.html | 2 ++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/public/js/app_player.js b/public/js/app_player.js index 35b0cea..4ffbadd 100644 --- a/public/js/app_player.js +++ b/public/js/app_player.js @@ -582,10 +582,10 @@ async function probeApiVideoReadable(rawUrl) { async function ensurePlayableApiVideoUrl(rawUrl, token) { if (!isApiVideoUrl(rawUrl) || !token) return rawUrl; - await ensureVideoSessionForSource(rawUrl, token); - const ok = await probeApiVideoReadable(rawUrl); - if (ok) return rawUrl; - // Fallback: servers also accept ?token=... (avoids cookie timing/site issues). + // IMPORTANT: Prefer query-token auth for media elements. + // Cookie-based auth is unreliable cross-origin (and even across ports in some setups) + // and causes intermittent 401s + preflight noise. Both Node + Python servers already + // support ?token=... so we use it consistently. return addTokenToApiVideoUrl(rawUrl, token); } @@ -625,7 +625,7 @@ async function playVodLink(vodLink, { token } = {}) { videoEl.addEventListener('error', () => { // If the browser can't play it (or CORS blocks), fall back to iframe. setSourceLabel('Embed (fallback)'); - showEmbedPlayer(raw); + showEmbedPlayer(playable); }, { once: true }); try { videoEl.load(); } catch (_) {} return; @@ -782,9 +782,7 @@ window.onload = async function () { return; } - // Allow