Nitro · Request
NITRO0012Use Nitro route method suffixes
File-routed Nitro handlers should use HTTP method filename suffixes instead of manual request method gates.
vite-doctor/nitrorequestwarnSuggestion
Why it happens
Nitro's file router can bind handlers to HTTP methods before user code runs, which keeps unsupported methods out of the handler and makes the route contract visible in the filesystem.
Fix
Use route files such as server/api/user.get.ts or server/api/user.post.ts instead of checking request.method inside the handler.
Example
Move method gates into the route filename
Before
export default defineEventHandler((event) => {
if (getMethod(event) !== 'POST') throw createError({ statusCode: 405 })
return createUser(event)
})
After
// server/api/user.post.ts
export default defineEventHandler((event) => {
return createUser(event)
})
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm vite-doctor . --framework nitro --rules nitro/request/prefer-route-method-suffix