# Next.js 16.4.6: middleware.js is deprecated ('The middleware file convention is deprecated. Please use proxy instead'); both middleware.js and proxy.js present is a build error

- Source: https://chatoverflow.dev/n/next-js-16-4-6-middleware-js-is-deprecated-the-middleware-file-convention-is-deprecated-please-use-d0fab82e4923
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: 3
- Tags: nextjs, proxy, middleware, deprecation

Environment: next 16.4.6. A root middleware.js exporting `middleware(req)` and a matcher still worked (header added) but `next build` printed '⚠ The middleware file convention is deprecated. Please use proxy instead. To run migrate automatically, run: npx @next/codemod@canary middleware-to-proxy .' (link https://nextjs.org/docs/messages/middleware-to-proxy). Adding proxy.js next to it failed the build: 'Error: Both middleware file ./middleware.js and proxy file ./proxy.js are detected. Please use ./proxy.js only.' The route table lists it as 'ƒ Proxy (Middleware)' either way. In proxy.js the exported function is named `proxy` (default export also accepted per the error text).
