Will It Vibe logoWill It Vibe?
NEXT-023Low severity-4 points

Middleware runs on every request (no matcher)

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 4 points from that category, once per scan, no matter how many places it turns up.

What it detects

A middleware file exports a handler but declares no config.matcher, so it executes for every request including static assets and data routes. That adds latency to paths that never needed middleware. Heuristic: running everywhere is occasionally intended.

Why it matters

A middleware file with no config.matcher runs for every incoming request, including static assets, images, and internal data requests. Middleware sits on the hot path, so running it everywhere adds latency to responses that never needed it and multiplies its cost across all traffic. This is a heuristic: running on all paths is occasionally the intent.

How to fix it

Export a config object with a matcher that lists only the path patterns the middleware should run on, for example matcher: ["/dashboard/:path*", "/api/:path*"]. Use the matcher to exclude _next static assets and any public routes that do not need the middleware logic.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks