fix: register gonertia middleware in router#53
Merged
felipekafuri merged 1 commit intoFeb 13, 2026
Conversation
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 <noreply@anthropic.com>
felipekafuri
approved these changes
Feb 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
c.Inertia.Middlewarein the Echo middleware chain viaecho.WrapMiddleware(), placed right beforemiddleware.InertiaProps()What this middleware does
X-Inertia-VersionheaderVary: X-Inertiaheader — Tells caches (CDN, proxy) that the response varies based on theX-InertiaheaderWhy it wasn't caught earlier
Currently all delete routes use
POST(e.g.,profile.POST("/delete", ...)), so the 302→303 issue doesn't manifest. However, any future route using DELETE/PUT/PATCH with a redirect would break.Test plan
go build -o /dev/null ./cmd/web— compiles without errorsmake test— all tests passing🤖 Generated with Claude Code