framework icon indicating copy to clipboard operation
framework copied to clipboard

404 Cannot find any route matching

Open qucode1 opened this issue 3 years ago • 3 comments

Environment


  • Operating System: Darwin
  • Node Version: v16.16.0
  • Nuxt Version: 3.0.0-rc.12
  • Nitro Version: 0.6.0
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: modules, ssr
  • Runtime Modules: @nuxtjs/[email protected]
  • Build Modules: -

Reproduction

https://github.com/qucode1/nuxt-api-route-issue/blob/master/server/api/reset-password.post.ts

Describe the bug

Server api routes that return undefined or nothing at all will run, but the server will return an error that does not help finding the issue:

export default defineEventHandler(async (event) => {
  try {
    console.log('resetPassword')
    return
  } catch (error) {
    console.log('reset password error', { error })
    return sendError(event, createError({
      ...error,
      statusMessage: error.message,
    }))
  }
})

to fix the issue you need to use event.res.end(), return null or anything else.

404 Cannot find any route matching /api/reset-password Bildschirmfoto 2022-10-28 um 18 00 14

Additional context

No response

Logs

No response

qucode1 avatar Oct 28 '22 16:10 qucode1