Skip to content

Comments

fix: prefer existing middleware.ts over proxy.ts for Next.js 16+#52

Merged
nicknisi merged 6 commits intomainfrom
nicknisi/fix-next-proxy-middleware
Feb 13, 2026
Merged

fix: prefer existing middleware.ts over proxy.ts for Next.js 16+#52
nicknisi merged 6 commits intomainfrom
nicknisi/fix-next-proxy-middleware

Conversation

@nicknisi
Copy link
Member

@nicknisi nicknisi commented Feb 13, 2026

Summary

  • The installer placed middleware/proxy files at the project root regardless of where app/ lives. For src/app/ projects, Next.js only discovers these files in src/ — a root-level file is silently ignored, causing withAuth() to fail at runtime.
  • Made app/ directory detection an explicit blocking step (Step 4) in the skill. All subsequent steps reference {APP_DIR} so the agent places files alongside app/.
  • Validator now detects middleware/proxy at the wrong level relative to app/ and reports it as an error.
  • Grader checks both root and src/ paths, and fails if both middleware.ts and proxy.ts coexist (Next.js 16 error E900).
  • All file path globs in grader and validation rules now match src/app/ projects.
  • Added existing-middleware test fixture with src/ directory structure — passes eval on first attempt.

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.
@nicknisi nicknisi merged commit 83f3ef0 into main Feb 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant