How do I disable nuxt default error redirection

You cannot disable the <nuxt-error> rendering from the nuxt configuration.

Another way is to hack the nuxt render as follows:

1/ open the file ./node_modules/@nuxt/vue-app/template/components/nuxt.js
2/ go to the render(h) method
3/ remove the error condition to always show the component:

  render (h) {

    // HACK TO SKIP ERROR
    this.nuxt.err = false

    // if there is no error
    if (!this.nuxt.err) {
      // Directly return nuxt child
      return h('NuxtChild', {
        key: this.routerViewKey,
        props: this.$props
      })
    }

    // ...
  }

nb: after each npm or yarn install the hack in the file above will be overwrite.


I found a hack with a nuxt plugin :

./plugins/errors.js

export default function({ app }) {
  app.nuxt.error = () => {}
}

./nuxt.config.js

module.exports = {
  ...
  plugins: [
    "~/plugins/errors.js",
  ],
}

Tags:

Vue.Js

Nuxt.Js