Nuxt/examples/with-errors/server/middleware/error.ts
Daniel Roe 5d58ef48af
feat(nitro, nuxt3): allow handling otherwise unhandled runtime errors (#3464)
Co-authored-by: pooya parsa <pyapar@gmail.com>
2022-03-11 09:22:16 +01:00

9 lines
198 B
TypeScript

import { useQuery, defineMiddleware } from 'h3'
export default defineMiddleware((req, res, next) => {
if ('api' in useQuery(req)) {
throw new Error('Server middleware error')
}
next()
})