Nitro · NITRO0031

Don't let two route files resolve to the same route

Reports a route file when another file in the same api/ or routes/ directory resolves to the same route, method, and environment, and Nitro keeps the other one. A method-less handler next to a method handler is not reported, and neither are overrides across Nuxt layers. Unresolved layers, environment overrides, custom scan directories or suffixes, and ignore options are evidence gaps.
NITRO0031vite-doctor/nitroroutingerrorSuggestion

Run this rule

pnpm vite-doctor . --framework nitro --rules nitro/routes/no-shadowed-file-handler

Why it matters

Nitro registers the first scanned file for each route, method, and environment and silently drops the rest. Two files such as api/users.ts and api/users/index.ts both serve /api/users, so one of them never runs and edits to it have no effect.

Delete or rename one of the files. Keep one handler per route, or give each file a method suffix when they handle different methods.

Example

Keep one file per route

Before

// server/api/users.ts
export default defineEventHandler(() => listUsers())

// server/api/users/index.ts
export default defineEventHandler(() => listActiveUsers())

After

// server/api/users.get.ts
export default defineEventHandler(() => listUsers())

// server/api/users.post.ts
export default defineEventHandler((event) => createUser(event))
Copyright © 2026