From f227ecd7c3277007cf8048b9f837eda3b0eef20f Mon Sep 17 00:00:00 2001 From: MaracaipeDev Date: Fri, 13 Feb 2026 10:13:17 -0300 Subject: [PATCH] fix: register gonertia middleware in router Add `echo.WrapMiddleware(c.Inertia.Middleware)` to the middleware chain in the router. This middleware is essential for the InertiaJS protocol: - Converts 302 redirects to 303 for PUT/PATCH/DELETE requests - Handles asset versioning for frontend cache busting - Sets the `Vary: X-Inertia` header - Redirects back on empty Inertia responses Without this, any future route using DELETE/PUT/PATCH with a redirect would break because the browser follows the redirect keeping the original HTTP method (per the Fetch API spec), resulting in 404s. Co-Authored-By: Claude Opus 4.6 --- pkg/handlers/router.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/handlers/router.go b/pkg/handlers/router.go index bdc0853..31ef3ca 100644 --- a/pkg/handlers/router.go +++ b/pkg/handlers/router.go @@ -57,6 +57,7 @@ func BuildRouter(c *services.Container) error { CookieSameSite: http.SameSiteStrictMode, ContextKey: context.CSRFKey, }), + echo.WrapMiddleware(c.Inertia.Middleware), middleware.InertiaProps(), // leave this as the last one )