N
Nuxt2y ago
Henrik

404 does not load error.vue

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.
8 Replies
Lovefield
Lovefield2y ago
Have you used throw createError({statusCode:404}) ?
Henrik
HenrikOP2y ago
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.
Lovefield
Lovefield2y ago
hmm... In my code it's working. Have you created the "error.vue" file and tried running Nuxt again?
No description
Henrik
HenrikOP2y ago
Is it working in production or locally? For me locally all good but Netlify refuses to load error.vue
Lovefield
Lovefield2y ago
Oh, yes is locally. As you say maybe that error is Netlify error.
xibman
xibman2y ago
createError({statusCode:404, fatal: true}) to be sure to have the redirection
Henrik
HenrikOP2y ago
Thank you @xibman that did the trick!
xibman
xibman2y ago
you're welcome !

Did you find this page helpful?