I'm trying to handle request errors on the ssr side, for this I use serverMiddleware, but the problem is that res.statusCode is always 200. Although in the browser I see the page crashed with 500 code. Feeling as if the middleware fires before my api requests. Is there any way to solve this problem?
server-middleware/logger.js
export default function (req, res, next) {
console.log('Server middleware', res.statusCode);
next()
}
nuxt.config.js
serverMiddleware: ['~/server-middleware/logger'],