Skip to content

fix: make middleware apply to routes regardless of registration order#3850

Open
SisyphusZheng wants to merge 2 commits into
freshframework:mainfrom
SisyphusZheng:fix/middleware-order-independent
Open

fix: make middleware apply to routes regardless of registration order#3850
SisyphusZheng wants to merge 2 commits into
freshframework:mainfrom
SisyphusZheng:fix/middleware-order-independent

Conversation

@SisyphusZheng

Copy link
Copy Markdown
Contributor

Problem #3844

Middleware registered AFTER a route does not wrap that route because segmentToMiddlewares snapshots the chain at command time.

Fix

Two-pass processing in applyCommandsInner: all middleware/build commands run first, then Route/Handler registration sees the complete segment tree.

Verification

  • Existing CSP tests: 11/11 pass
  • New order test: CSP after route now works correctly

Closes #3844

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSP middleware does not work properly

1 participant