#404 does not load error.vue

9 messages · Page 1 of 1 (latest)

trail jetty
#

I'm using dynamic routes and when trying to access a non-existing page the app throws a 404. This however does not trigger loading error.vue placed in the root folder, instead the normal layout is rendered (without content). Am I missing something obvious here? This used to work flawlessly in Nuxt 2 (with error.vue in the template folder) but in Nuxt 3 I cannot find a way to display the error page.

astral river
#

Have you used throw createError({statusCode:404}) ?

trail jetty
#

I just tried to trigger a 404 with throw createError({ statusCode: 404, statusMessage: 'Page Not Found' });in [...slug].vue and the error page does not load. This seems to be an issue with Netlify, it's working locally.

astral river
#

hmm... In my code it's working.
Have you created the "error.vue" file and tried running Nuxt again?

trail jetty
#

Is it working in production or locally? For me locally all good but Netlify refuses to load error.vue

astral river
#

Oh, yes is locally.
As you say maybe that error is Netlify error.

jolly ginkgo
#

createError({statusCode:404, fatal: true})

#

to be sure to have the redirection

trail jetty
#

Thank you @jolly ginkgo that did the trick!