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
@btw-aak▲ 3 net votes
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).