diff --git a/server/router/handler/auth.go b/server/router/handler/auth.go index 87ee06d..20c5c28 100644 --- a/server/router/handler/auth.go +++ b/server/router/handler/auth.go @@ -20,6 +20,11 @@ func HandleAuth(sc context.Context, action string) echo.HandlerFunc { return LnAuth(sc, c, action) } + // on session guard redirects to /login, + // we need to make sure that HTMX selects and targets correct element + c.Response().Header().Add("HX-Retarget", "#content") + c.Response().Header().Add("HX-Reselect", "#content") + return pages.Auth(mapAction(action)).Render(context.RenderContext(sc, c), c.Response().Writer) } } diff --git a/server/router/middleware/session.go b/server/router/middleware/session.go index 2bb17d1..12689d2 100644 --- a/server/router/middleware/session.go +++ b/server/router/middleware/session.go @@ -47,7 +47,7 @@ func SessionGuard(sc context.Context) echo.MiddlewareFunc { session := c.Get("session") if session == nil { // this seems to work for non-interactive and htmx requests - return c.Redirect(http.StatusTemporaryRedirect, "/login") + return c.Redirect(http.StatusSeeOther, "/login") } return next(c) }