Skip to content

Codemod/middleware-to-proxy: file rename is skipped when no file content changes were necessary #86478

@vanruch

Description

@vanruch

Link to the code that reproduces this issue

https://github.com/vanruch/next-repro - result of running npm create next-app --example auth next-repro

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    MiddlewareRelated to Next.js Middleware.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions