Alaa
Nuxt2 displays wrong meta tags when the page is deleted
To Summarize:
I'm stuck on this Nuxt 2 issue: when a user visits a non-existent profile URL, I throw an error in the
fetch()
method. This correctly triggers my custom error component, but the meta tags in the <head>
(like title, description, og tags) remain from the last successful page and do not update or clear.
Here’s what I have:
The page fetches profile data in async fetch() and sets up metadata in head().
If the fetch fails, I throw a formatted error which renders a custom <error-component />.
This is all wrapped inside <client-only>, including the error component being wrapped inside it too.
I'm suspicious that head() isn't being recalculated on error, or maybe client-only is preventing it somehow?
Has anyone run into this before? What's the best way to force a proper head/meta reset when a page results in a 404 or fetch error?
Thanks in advance 🙏7 replies