From 8d84e29d34a5e1438adb2a6eac99b7295c311a70 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sun, 14 Jul 2024 12:43:16 +0200 Subject: [PATCH] Improve htmx comment about 302 Found in session check --- server/router/handler/auth.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/router/handler/auth.go b/server/router/handler/auth.go index b96676d..1f2f033 100644 --- a/server/router/handler/auth.go +++ b/server/router/handler/auth.go @@ -168,9 +168,10 @@ func HandleSessionCheck(sc context.Context) echo.HandlerFunc { return c.JSON(http.StatusNotFound, "session not found") } - c.Response().Header().Set("HX-Location", "/") - // htmx requires a 200 response to follow redirects + // HTMX can't follow 302 redirects with a Location header + // it requires a HX-Location header and 200 response instead // see https://github.com/bigskysoftware/htmx/issues/2052 + c.Response().Header().Set("HX-Location", "/") return c.JSON(http.StatusOK, nil) } }