No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Custom SSR error handling in extension.js causing dev server to fail

    Help
    1
    1
    154
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • O
      omnichronous last edited by

      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 error handleError is not defined in client/node_modules/@quasar/app/lib/dev-server.js.

      Alternatively, trying to execute res.redirect('/error500') in the app.get() callback leads to a redirect loop.

      So how would redirecting to a custom route work in dev mode?

      1 Reply Last reply Reply Quote 0
      • First post
        Last post