Unexpected regression with middlewares since v6.4.6 #115
-
Continuation from discussion #110 There's actually an unexpected behavior that gets introduced since 6.4.6, and also persists in 6.4.7, that I did not previously notice when I claimed that 6.4.6 fixed the discussed issue I confirmed it on a much simpler project so I didn't notice, whoops Basically, when you have multiple middlewares initiated for multiple routes like the following example: // Init separate rate limiter pools
server.use('/api/login', middlewareA)
server.use('/api/album/zip', middlewareB)
server.use('/api/tokens/change', middlewareC)
server.use('/api', middlewareD) // last as catch-all for any other /api/* paths It appears that any requests to any And even requests to exact paths such as |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
So regarding the execution of the middlewares. They are executed in the following order: With that in mind, is it correct to assume that the correct executions for a request to |
Beta Was this translation helpful? Give feedback.
So regarding the execution of the middlewares. They are executed in the following order:
1 - Global Middlewares in the order they were registered.
2 - Local Middlewares (Global but with with a certain path specification) in the order they were registered.
3 - Route-Specific Middlewares (Specified when creating the route itself) in the order they were specified.
With that in mind, is it correct to assume that the correct executions for a request to
/api/login
with the above middlewares should be the following?1 - middlewareD()
2 - middlewareA()