Fix · Vercel and deploying
Middleware error: every page fails
Not checked against the vendor's current screens
What you may see
- All pages return 500 or MIDDLEWARE_INVOCATION_FAILED
- It started after I added login checks or redirects
Most likely cause
The code that runs before every request (middleware) throws an error or uses something the edge environment does not support.
Check first (about two minutes)
- Check the runtime logs: do all routes fail at once with the same message?
The fix prompt
What you type here never leaves your browser. The search runs on this page, and nothing is sent to a server or to an AI.
Kept only in this browser, on this device. Keys and passwords are removed before anything is saved.
Prompt language
Paste it into Claude, ChatGPT, Gemini or Cursor, then follow what it says.
After you tried it, did it work?
Steps
- Read the middleware (or proxy) file and the log message.
- Find the line that throws (a missing variable, a package that needs Node features, a bad pattern in the matcher) and fix it.
- Keep the middleware small: make it skip static files and public assets.
Do not do this
- Do not run heavy database work in middleware.
- Do not disable login protection to make pages load.