fix: migrate middleware.ts → proxy.ts to fix 500 MIDDLEWARE_INVOCATION_FAILED#72
Draft
DealPatrol wants to merge 1 commit into
Draft
fix: migrate middleware.ts → proxy.ts to fix 500 MIDDLEWARE_INVOCATION_FAILED#72DealPatrol wants to merge 1 commit into
DealPatrol wants to merge 1 commit into
Conversation
Next.js 16 deprecated the `middleware` file convention in favour of `proxy`. The deprecated `middleware.ts` was causing MIDDLEWARE_INVOCATION_FAILED 500 errors on every request hitting repofuse.com. Changes: - Rename middleware.ts → proxy.ts (required by Next.js 16) - Return NextResponse.next() explicitly instead of bare `return` (undefined is not a valid response in the Edge runtime and triggers the 500) - Wrap auth.protect() in its own try/catch to redirect gracefully on Clerk auth failures rather than surfacing an unhandled exception - Add outer try/catch so any unexpected error redirects cleanly instead of propagating as a 500 https://claude.ai/code/session_018w2VTF3yhVhavRJ8rTVWaV
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
middlewarefile convention in favour ofproxy. The oldmiddleware.tswas still being compiled but was failing at runtime withMIDDLEWARE_INVOCATION_FAILEDon every request, producing the 500 error visible on repofuse.com.middleware.ts→proxy.ts(the file Next.js 16 actually runs).NextResponse.next()explicitly instead of barereturn— returningundefinedis not a valid Edge runtime response and triggers the 500.auth.protect()in its owntry/catchso a Clerk auth failure redirects gracefully instead of propagating as an unhandled exception.try/catchon the whole handler so any unexpected error redirects to/?error=middleware_errorrather than surfacing as a 500.The auth logic itself (Clerk when configured, legacy GitHub OAuth cookies otherwise) is unchanged.
Test plan
middlewaredeprecation is gone/dashboard→ redirects to/?error=auth_required/dashboard→ loads normally/,/pricing, etc.) → load without errorshttps://claude.ai/code/session_018w2VTF3yhVhavRJ8rTVWaV
Generated by Claude Code