Custom SSR error handling in extension.js causing dev server to fail
-
So I’m trying to customize the error pages in SSR mode. I have a custom route set up to show a 500 error page and I’m following the instructions from the Quasar docs and editing
/src-ssr/extension.js
in order to see my changes in dev mode. I’m basically testing with code copied from/src-ssr/index.js
and my file looks rougly like this:module.exports.extendApp = function ({ app, ssr }) { app.get('*', (req, res) => { res.setHeader('Content-Type', 'text/html') ssr.renderToString({ req, res }, (err, html) => { res.redirect('/error500') }) }) }
With this code, when I try to access any route on the app I get a dev server error. Anything executed in the
ssr.renderToString()
callback throws the errorhandleError is not defined
inclient/node_modules/@quasar/app/lib/dev-server.js
.Alternatively, trying to execute
res.redirect('/error500')
in theapp.get()
callback leads to a redirect loop.So how would redirecting to a custom route work in dev mode?