From 505fc48b23eea01b57e8aaa44444cb70b0ebf457 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Tue, 13 Oct 2026 14:52:19 -0400 Subject: [PATCH] =?UTF-8?q?fix(web):=20profile=20save=20silently=20died=20?= =?UTF-8?q?under=20htmx=202=20=E2=80=94=20invalid-JSON=20hx-headers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reproduced on the emulator via CDP: clicking Save Changes fired the submit event, something preventDefault-ed it, and htmx aborted while parsing hx-headers — 'Bearer ' + localStorage.getItem('token') is a JS expression, and htmx 2 requires valid JSON (or a js: prefix) there. The PUT never left the browser: zero htmx lifecycle events, no console error, no toast. My earlier HX-Refresh fix was correct but unreachable — the request died before it could ever be answered. The header was htmx-1.x legacy and redundant: the browser already sends the token cookie, which the auth middleware accepts. Removed hx-headers from the profile form and both password-reset buttons. Verified end-to-end in the emulator browser via CDP: Edit → change timezone → Save → PUT 200, HX-Refresh reload, DB updated. The tab reload mid-probe is the fix working. --- templates/profile_form.templ | 3 --- templates/profile_form_templ.go | 16 ++++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/templates/profile_form.templ b/templates/profile_form.templ index 6c1b4ce6..2d3ecfa7 100644 --- a/templates/profile_form.templ +++ b/templates/profile_form.templ @@ -5,7 +5,6 @@ templ ProfileForm(user User, actionURL string, requireCurrentPassword bool, show hx-put={ actionURL } hx-target="#profile-result" hx-swap="innerHTML" - hx-headers='{"Authorization": "Bearer " + localStorage.getItem("token")}' class="space-y-8" >
@@ -150,7 +149,6 @@ templ ProfileForm(user User, actionURL string, requireCurrentPassword bool, show