Vue-meta: __dangerouslyDisableSanitizersByTagID does not work in Nuxt SSR

Created on 6 Jan 2021  路  2Comments  路  Source: nuxt/vue-meta

I am using the __dangerouslyDisableSanitizersByTagID option but it does not work on a hard refresh / static generation of the HTML from within Nuxt.js.

I did, however, notice it's working when navigating the pages of my site via the router (so client-side only it seems).

Incorrect: Viewing page source (browser view source and running npm run generate) I see something like:
<script data-n-head="ssr" vmid="ldjson-schema" type="application/ld+json"> {&quot;@context&quot;:&quot;https://schema.org&quot;} </script>

Correct: ...navigating the site via Vue router I see (in Chrome dev tools):
<script data-n-head="ssr" vmid="ldjson-schema" type="application/ld+json"> {"@context":"https://schema.org"} </script>

This certainly feels like a bug to me but I'd be happy to hear if I'm doing anything wrong. I was following the documentation:
https://vue-meta.nuxtjs.org/api/#dangerouslydisablesanitizersbytagid

head() {
  return {
    meta: metas, // Array of meta objects.
    script: scripts, // Array of script objects.
    __dangerouslyDisableSanitizersByTagID: {
      'ldjson-schema': ['innerHTML'], // Matches the ID I set in the script.
    }
  }
}

I'm not seeing any console errors in either terminal or the browser.

question

Most helpful comment

I did it in the same way and I have the same problem.But then I found this: https://github.com/nuxt/nuxt.js/issues/241#issuecomment-363395895

So, you have to use hid instedof vmid to set tag id.

All 2 comments

I did it in the same way and I have the same problem.But then I found this: https://github.com/nuxt/nuxt.js/issues/241#issuecomment-363395895

So, you have to use hid instedof vmid to set tag id.

I did it in the same way and I have the same problem.But then I found this: nuxt/nuxt.js#241 (comment)

So, you have to use hid instedof vmid to set tag id.

You are absolutely correct! That worked perfectly.

I guess it's not a bug then but lacking in documentation?

Thank you so much for your reply.

Was this page helpful?
0 / 5 - 0 ratings