nextjs - 💡(How to fix) Fix Codemod/middleware-to-proxy: file rename is skipped when no file content changes were necessary [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#86474Fetched 2026-04-08 02:10:46
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×2closed ×1commented ×1issue_type_added ×1

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0: Wed Sep 17 21:41:50 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6030
  Available memory (MB): 18432
  Available CPU cores: 12
Binaries:
  Node: 23.11.1
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: 9.14.3
Relevant Packages:
  next: 16.0.3
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/vercel/next.js/tree/v15.5.6/examples/auth

To Reproduce

  1. Create create simple middleware.ts
  2. Run npx @next/codemod@latest middleware-to-proxy
  3. File is not renamed

Current vs. Expected behavior

Expected middleware.ts to be renamed to proxy.ts

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0: Wed Sep 17 21:41:50 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6030
  Available memory (MB): 18432
  Available CPU cores: 12
Binaries:
  Node: 23.11.1
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: 9.14.3
Relevant Packages:
  next: 16.0.3
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Middleware

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

If there're no changes necessary in the middleware file, the codemod returns in this line https://github.com/vercel/next.js/blob/canary/packages/next-codemod/transforms/middleware-to-proxy.ts#L78 And the file rename in line 85 is skipped

extent analysis

TL;DR

The middleware-to-proxy codemod may not rename the middleware.ts file to proxy.ts if no changes are necessary in the middleware file.

Guidance

  • Review the middleware.ts file to ensure it requires changes to be converted to a proxy file.
  • Check the codemod script to see if it correctly handles cases where no changes are necessary in the middleware file.
  • Verify that the middleware-to-proxy codemod is correctly configured and executed.
  • Consider manually renaming the middleware.ts file to proxy.ts if the codemod does not perform the rename.

Notes

The issue may be specific to the next version (16.0.3) or the @next/codemod version (latest) being used. The codemod script's behavior when no changes are necessary in the middleware file may be the root cause of the issue.

Recommendation

Apply workaround: Manually rename the middleware.ts file to proxy.ts if the codemod does not perform the rename, as the codemod's current implementation may skip the rename if no changes are necessary.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING