Skip to content

fix: correct stripPath and addPrefix middleware order#4190

Merged
Siumauricio merged 1 commit intocanaryfrom
fix/traefik-strip-path-middleware-order
Apr 9, 2026
Merged

fix: correct stripPath and addPrefix middleware order#4190
Siumauricio merged 1 commit intocanaryfrom
fix/traefik-strip-path-middleware-order

Conversation

@Siumauricio
Copy link
Copy Markdown
Contributor

@Siumauricio Siumauricio commented Apr 9, 2026

Summary

  • Swaps the order of stripPrefix and addPrefix middleware in Traefik router config so stripPrefix runs first
  • When both stripPath and internalPath are set, requests like /public/api/users now correctly resolve to /app/v2/api/users instead of /app/v2/public/api/users
  • Adds test verifying middleware ordering when both options are active

Closes #4061

Greptile Summary

This PR fixes a middleware ordering bug in Traefik router configuration where addPrefix was registered before stripPrefix, causing requests like /public/api/users to incorrectly resolve to /app/v2/public/api/users instead of /app/v2/api/users. The fix swaps the push order so stripPrefix is 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

…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
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Apr 9, 2026
@Siumauricio Siumauricio merged commit b4c57b6 into canary Apr 9, 2026
5 checks passed
@Siumauricio Siumauricio deleted the fix/traefik-strip-path-middleware-order branch April 9, 2026 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Requests receive incorrect path when both Strip Path and Internal Path are configured

1 participant