You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Display which file is detected as middleware in error messages
Non-Goals
Background
When output: 'export'(for static exports) is configured, the build fails with the error: ⨯ Middleware cannot be used with "output: export".
The problem is that the error message doesn't specify which file is causing the conflict. In my case, I was using proxy.ts (based on https://nextjs.org/docs/app/api-reference/file-conventions/proxy) rather than middleware.ts. Next.js provided no clue in the logs as to which file triggered the error, making it difficult to debug.
While I was able to identify that proxy.ts was being treated as middleware since I changed the file name myself, this might be very confusing for people who are new to the framework.
Proposal
⨯ Middleware in 'proxy.ts' cannot be used with "output: export"
Not sure but maybe this kind of simple change would save developers time by immediately showing which file needs to be fixed.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Goals
Display which file is detected as middleware in error messages
Non-Goals
Background
When
output: 'export'(for static exports) is configured, the build fails with the error:⨯ Middleware cannot be used with "output: export".The problem is that the error message doesn't specify which file is causing the conflict. In my case, I was using
proxy.ts(based on https://nextjs.org/docs/app/api-reference/file-conventions/proxy) rather thanmiddleware.ts. Next.js provided no clue in the logs as to which file triggered the error, making it difficult to debug.While I was able to identify that
proxy.tswas being treated as middleware since I changed the file name myself, this might be very confusing for people who are new to the framework.Proposal
⨯ Middleware in 'proxy.ts' cannot be used with "output: export"Not sure but maybe this kind of simple change would save developers time by immediately showing which file needs to be fixed.
All reactions