Nitro · Server
NITRO0002Do not use useNuxtApp in Nitro routes
Nitro handlers run outside the Nuxt app runtime, so useNuxtApp() is unavailable.
vite-doctor/nitroservererrorSuggestion
Why it happens
Nitro request handlers execute in the server runtime with an event object, not inside Vue or Nuxt app setup. App composables rely on Nuxt app instance state that does not exist there.
Fix
Use event-aware Nitro, h3, or server utilities that receive the request event.
Example
Avoid useNuxtApp in Nitro
Before
export default defineEventHandler(() => {
const nuxtApp = useNuxtApp()
return nuxtApp.payload
})
After
export default defineEventHandler((event) => {
return useRuntimeConfig(event).public
})
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/context/no-usenuxtapp-in-nitro