fix: correct stripPath and addPrefix middleware order#4190
Merged
Siumauricio merged 1 commit intocanaryfrom Apr 9, 2026
Merged
fix: correct stripPath and addPrefix middleware order#4190Siumauricio merged 1 commit intocanaryfrom
Siumauricio merged 1 commit intocanaryfrom
Conversation
…n config When both stripPath and internalPath are configured, addPrefix was pushed before stripPrefix causing incorrect path rewriting (e.g. /app/v2/public/api instead of /app/v2/api). Traefik executes middlewares in array order, so stripPrefix must come first. Closes #4061
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
stripPrefixandaddPrefixmiddleware in Traefik router config sostripPrefixruns firststripPathandinternalPathare set, requests like/public/api/usersnow correctly resolve to/app/v2/api/usersinstead of/app/v2/public/api/usersCloses #4061
Greptile Summary
This PR fixes a middleware ordering bug in Traefik router configuration where
addPrefixwas registered beforestripPrefix, causing requests like/public/api/usersto incorrectly resolve to/app/v2/public/api/usersinstead of/app/v2/api/users. The fix swaps the push order sostripPrefixis always registered first, and adds a focused test to lock in the correct ordering.Confidence Score: 5/5
This PR is safe to merge — it corrects a clear middleware ordering bug with no regressions introduced.
The change is minimal and targeted: a two-block swap in a single function, backed by a new test that directly asserts the correct ordering. The logic is straightforwardly correct for Traefik's sequential middleware model, and no existing tests are broken. No P0/P1 findings identified.
No files require special attention.
Reviews (1): Last reviewed commit: "fix: swap stripPrefix and addPrefix midd..." | Re-trigger Greptile