fix(dashboard): PUT the handoff bundle through the app's API base

The backend's upload_url embeds the request host; behind the dev proxy that is the Docker-internal backend:8000, which the browser cannot resolve, so the ZIP PUT died as a bare 'Failed to fetch' and aborted the job. Use /api/uploads/<id> via the app's own base instead, and label handoff failures clearly so they are not mistaken for a process error.
This commit is contained in:
pedro-bento 2026-10-05 20:56:47 +01:00
parent 6aa3b0ec82
commit d9e6b6ce04

View file

@ -705,8 +705,12 @@ function App() {
});
if (!createRes.ok) throw new Error(`Handoff upload failed: ${readableError(await createRes.text())}`);
const slot = await createRes.json();
if (!slot?.upload_url) throw new Error('Handoff upload failed: the server returned no upload URL.');
const putRes = await apiFetch(slot.upload_url, {
if (!slot?.upload_id) throw new Error('Handoff upload failed: the server returned no upload id.');
// PUT through the app's own API base rather than the absolute
// `upload_url` the server returns: behind the dev proxy that URL's host
// is the Docker-internal `backend:8000`, which the browser cannot
// resolve, so the request dies with a bare "Failed to fetch".
const putRes = await apiFetch(`/api/uploads/${encodeURIComponent(slot.upload_id)}`, {
method: slot.method || 'PUT',
headers: { 'Content-Type': 'application/zip' },
body: data.handoffFile,
@ -716,6 +720,11 @@ function App() {
handoffId = putData.upload_id || slot.upload_id || null;
if (!handoffId) throw new Error('Handoff upload failed: the server returned no upload id.');
setLogs((l) => [...l, 'Handoff bundle attached — transcription will be skipped.']);
} catch (e) {
const msg = e?.message || String(e);
throw new Error(
msg.startsWith('Handoff upload failed') ? msg : `Handoff upload failed: ${msg}`,
);
} finally {
setHandoffUploading(false);
}