Search code examples
vue.jserror-handlingnuxt.jsserver-side-renderingbugsnag

Use Express.js in an existing Nuxt.js project


I have a project built with Nuxt.js and I want to use express to be able to report bugsnag errors on my asyncData method etc.

How would I go to import that? I suppose is not as simple as npm install express --save.

I already have an api written in PHP so I would not use that as an api or anything else.

Is it overkill? Or is it a necessary evil? :D


Solution

  • You dont need express to handle errors in asyncData. To handle errors in asyncData/fetch on ssr you just need to hook into render:errorMiddleware. See sentry plugin for nuxt for example

    But it would only catch errors that happens on SSR. On client unfortunately that wont catch anything ( as well as express wont do anything for client). There is a bug for this in nuxt see here