From b845957314a13516e409f80128d6e5589b6ea741 Mon Sep 17 00:00:00 2001 From: Dorian Date: Tue, 16 Jun 2026 15:09:45 +0100 Subject: [PATCH] fix: don't require report_id/token on submit success MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The deployed storage-free worker returns { ok: true } without report_id/report_token, but the submit handler threw 'Your plan could not be saved' whenever they were absent — showing an error even though the email sent. Treat the worker's ok response as success and only capture the tokens when the D1 worker provides them (restore link). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/App.vue | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/App.vue b/src/App.vue index e78a239..e6503cb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1779,13 +1779,20 @@ function submitCapture(e) { return res.json() }) .then(data => { - if (!data || !data.report_id || !data.report_token) { + // The HTTP res.ok check above already confirmed the worker accepted + // the submission (email sent). report_id/report_token are only + // returned by the D1-backed worker; capture them when present so the + // email restore link works, but don't require them — the storage-free + // worker sends the plan without persisting anything. + if (data && data.ok === false) { throw new Error(currentLang === 'de' - ? 'Dein Plan konnte gerade nicht gespeichert werden. Bitte versuche es erneut.' - : 'Your plan could not be saved just now. Please try again.') + ? 'Dein Plan konnte gerade nicht per E-Mail gesendet werden. Bitte versuche es erneut.' + : 'Your plan could not be emailed just now. Please try again.') + } + if (data && data.report_id && data.report_token) { + answers._report_id = String(data.report_id) + answers._report_token = String(data.report_token) } - answers._report_id = String(data.report_id) - answers._report_token = String(data.report_token) saveState() showSuccess() })