H3 · Middleware

H30020Match nested paths in H3 v2 middleware

Flags app.use("/path", middleware) with a path that has no wildcard. Mounting a sub-app with app.use("/path", app) still matches nested paths and is not flagged.

Why it happens

In H3 v1, app.use("/api", fn) ran for every path under /api. In H3 v2 a middleware path is a route pattern, so "/api" matches only /api itself and the middleware skips every nested route.

Fix

Add a wildcard, such as app.use("/api/**", fn), or keep the exact path when the middleware is meant for that one route.

Example

Match nested paths with a wildcard

Before

app.use("/api", auth)

After

app.use("/api/**", auth)

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --extends auto,h3/strict --rules h3/middleware/no-exact-path-use
Copyright © 2026