diff --git a/chrome-extension/popup.js b/chrome-extension/popup.js index 1ee352e..eff88cc 100644 --- a/chrome-extension/popup.js +++ b/chrome-extension/popup.js @@ -14,6 +14,8 @@ let connected = false; if (stored.config) config = { ...config, ...stored.config }; if (stored.token && stored.token !== null) authToken = stored.token; if (stored.mode) uploadMode = stored.mode; + // Default to HTTP if no mode saved + if (!stored.mode) uploadMode = 'http'; document.getElementById('cfg-server').value = config.serverUrl; document.getElementById('cfg-user').value = config.username; @@ -232,6 +234,17 @@ function updateBtn() { // ==================== UPLOAD ==================== async function startUpload() { if (!connected) { showStatus('Not connected to server', 'error'); return; } + // If UDP mode selected but relay not configured, fall back to HTTP silently + if (uploadMode === 'udp') { + try { + const health = await apiFetch('GET', '/api/health'); + if (!health.relayConfigured) { + showStatus('⚠️ UDP relay not configured — switching to HTTP', 'loading'); + setMode('http'); + await new Promise(r => setTimeout(r, 1000)); + } + } catch (_) {} + } const pending = selectedFiles.filter(f => f.status === 'pending'); document.getElementById('upload-btn').disabled = true; const prefix = document.getElementById('folder-select').value;