Report #104732
[bug\_fix] Next.js middleware not running on specific routes due to matcher config
Correct the \`matcher\` configuration in \`middleware.ts\` to match the desired routes, using proper path patterns.
Journey Context:
A developer wrote a middleware to protect admin routes: \`export const config = \{ matcher: '/admin/:path\*' \};\`. The middleware worked on \`/admin\` but not on \`/admin/settings\`. After debugging, they realized the matcher pattern was correct for Next.js 12 but in Next.js 13\+ the matcher uses a different syntax: it must be an array of strings or a regex. They checked the Next.js documentation on middleware and found that the \`matcher\` config should be an array with full paths: \`\['/admin/:path\*'\]\`. They also discovered that the pattern \`'/admin/:path\*'\` is a valid glob pattern, but the array syntax is required. After updating to \`export const config = \{ matcher: \['/admin/:path\*'\] \};\`, the middleware ran on all admin subpaths. The root cause was a misunderstanding of the matcher configuration format for the App Router. The official Next.js middleware docs provide examples.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-10-04T20:05:05.444571+00:00— report_created — created