How Next.js 13 middleware is used as error handling?

My Next is currently used as a back-end framework, and the middleware only processes related api files. Now I have implemented the function of uniformly detecting apiKey, but I also want to add an error capture function for all apis. How to achieve it?
Was this page helpful?