hoangvvo / next-connect

The TypeScript-ready, minimal router and middleware layer for Next.js, Micro, Vercel, or Node.js http/http2
https://www.npmjs.com/package/next-connect
MIT License
1.62k stars 65 forks source link

hiding error stacktrace #186

Closed ghost closed 2 years ago

ghost commented 2 years ago

I am currently in dev and next-connect shows the whole error stacktrace to the frontend (client) is this intended ? using nextjs. Couldnt find any hide mechanism ! Thanks

hoangvvo commented 2 years ago

You should define the onError function:


const handler = nc({
  onError: (err, req, res, next) => {
    console.error(err.stack); // log error
    res.status(500).end("Something broke!"); // show a specific message
  },
})