fix: prefer existing middleware.ts over proxy.ts for Next.js 16+#52
Merged
fix: prefer existing middleware.ts over proxy.ts for Next.js 16+#52
Conversation
When a Next.js 16+ project already has middleware.ts, the installer would create proxy.ts alongside it. Next.js ignores proxy.ts when middleware.ts exists, causing withAuth() to fail at runtime. The skill now instructs the agent to use the existing middleware.ts instead, and the grader detects the conflict as a failing check.
Next.js only watches for middleware/proxy files in the parent directory
of app/. For src/app/ projects, a middleware.ts at the project root is
silently ignored, causing withAuth() to fail at runtime.
- Skill now instructs agent to detect where app/ lives and place the
file at the same level
- Validator detects middleware/proxy at the wrong level relative to app/
- Grader checks both root and src/ for middleware/proxy files
- Added existing-middleware test fixture (src/ directory structure)
- Validation rules now match {,src/}{middleware,proxy}.{ts,js}
The skill documented placement rules but buried them in notes the agent skipped. Now Step 4 is an explicit blocking step that locates app/ and sets APP_DIR before any files are created. All subsequent steps reference APP_DIR so the agent can't default to project root.
The AuthKitProvider check and callback route validation only matched
app/**/*.tsx, missing src/app/ projects. Added {,src/} prefix to all
file path globs.
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
app/lives. Forsrc/app/projects, Next.js only discovers these files insrc/— a root-level file is silently ignored, causingwithAuth()to fail at runtime.app/directory detection an explicit blocking step (Step 4) in the skill. All subsequent steps reference{APP_DIR}so the agent places files alongsideapp/.app/and reports it as an error.src/paths, and fails if bothmiddleware.tsandproxy.tscoexist (Next.js 16 error E900).src/app/projects.existing-middlewaretest fixture withsrc/directory structure — passes eval on first attempt.