Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkg/handlers/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ func BuildRouter(c *services.Container) error {
CookieHTTPOnly: false, // must be false so JS (Axios) can read it
CookieSameSite: http.SameSiteStrictMode,
ContextKey: context.CSRFKey,
ErrorHandler: func(err error, ctx echo.Context) error {
// Clear the stale CSRF cookie so a fresh token is set on redirect.
ctx.SetCookie(&http.Cookie{
Name: "XSRF-TOKEN",
Value: "",
Path: "/",
MaxAge: -1,
})
return ctx.Redirect(http.StatusFound, ctx.Request().URL.Path)
},
}),
echo.WrapMiddleware(c.Inertia.Middleware),
middleware.InertiaProps(), // leave this as the last one
Expand Down
Loading