Improve htmx comment about 302 Found in session check

This commit is contained in:
ekzyis 2024-07-14 12:43:16 +02:00
parent 738d511f01
commit 8d84e29d34
1 changed files with 3 additions and 2 deletions

View File

@ -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)
}
}