You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Scan for route-based middleware routes/[server].middleware.ts #3880
Middleware can be applied globally or via object syntax at the moment. This makes route (group) based middleware hard to apply and possibly error prone, e.g. forgetting to add authorization to a single endpoint could lead to a security issue and code repetition.
Instead, having route-based middleware with the suffix pattern routes/[server].middleware.ts automatically apply to the route (and all possible child routes) would be helpful, reducing the need for code duplicates and risk of forgetting to add middleware.
Additional information
Would you be willing to help implement this feature?
Reacted by Pooya Parsa, Njenga Muriu and Carlos Duran
Now that the v3 RC is out, I'd like to pick this up, since #4845 reserved the .middleware suffix for it. The plan is to have the route scanner treat routes/[server].middleware.ts as middleware for that route and its child routes, per the issue. Is that the shape you want, and is anyone already on it?
I use AI assistance when working on patches, and I check and test everything before submitting.
Activity
coderabbitai commentedon Dec 16, 2025
🔗 Similar Issues
Related Issues
👤 Suggested Assignees
Enable issue planning
To enable issue planning, add the following to your
.coderabbit.yaml:You can then request a plan by commenting
@coderabbitai planon any issue.🧪 Issue enrichment is currently in early access.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord or schedule a call!
IslamElsayed commentedon Nov 1, 2026
Now that the v3 RC is out, I'd like to pick this up, since #4845 reserved the
.middlewaresuffix for it. The plan is to have the route scanner treatroutes/[server].middleware.tsas middleware for that route and its child routes, per the issue. Is that the shape you want, and is anyone already on it?I use AI assistance when working on patches, and I check and test everything before submitting.