fix: use page extensions for middleware files#595
Conversation
|
/bigbonk review |
commit: |
|
There was a problem hiding this comment.
Good change — middleware/proxy file discovery should respect pageExtensions just like route scanning does. The ordering fix in index.ts (moving the call after config is loaded) is correct, and the tests cover the new behavior well.
Two things to consider:
.mjs regression risk — The old hardcoded lists included .mjs for both proxy and middleware files. The default pageExtensions are ["tsx", "ts", "jsx", "js"], which does not include mjs. Any existing project with proxy.mjs or middleware.mjs that hasn't explicitly added "mjs" to their pageExtensions in next.config.js will silently lose middleware detection after this change. This matches the route scanning behavior (which also wouldn't pick up .mjs routes without explicit config), so it's arguably correct — but it's a subtle breaking change worth noting in case anyone reports it.
findInstrumentationFile follow-up — server/instrumentation.ts still uses a hardcoded file list with the same pattern this PR is fixing. Worth a follow-up to update it for consistency.
|
Review posted on PR #595. Here's a summary of what I found: The PR is solid. It unifies middleware/proxy file discovery with the same I flagged two items:
|
f3f3410 to
231c67f
Compare
middleware and proxy files should use next config page extensions where available, similar to routes.