Open GalacticHypernova opened 1 year ago
Nice spot. Would you be able to provide a reproduction? 🙏
Thank you! As I mentioned, the reproduction is having that directive in your content security policy, that's really all that is needed to recreate the issue. If need be, I can share my project privately where I tested it, but the content of the page does not really matter from what I checked. Even if it's just a generic rules page and is completely static it still (in my case) conflicts and errors out. (The reason I would like to share it privately in case necessary is it's a personal project of mine for an upcoming thing which I don't feel comfortable sharing publicly)
Also, I just found out I forgot to update. I thought maybe it was a 3.4.3 issue but 3.5.1 is also affected, so I will just update the environment. Just wanted to let you know why it would look different when you check this again. @danielroe
Might be related : https://github.com/vitejs/vite/issues/10553
@Hebilicious it might, but as far as I'm aware I didn't see that it was from vite, unlike my newer CSP conflict issue nuxt/nuxt#21268 where it specifically errored on vite's end. However I can try to see if this one is also related to it because as I mentioned, this doesn't even happen every single time.
Indeed, I believe this is likely coming from vite (though it's possible it's from vue). You can try using the webpack builder to see if the issue is replicable without vite or https://stackblitz.com/github/nuxt-contrib/vue3-ssr-starter to see if it is replicable without nuxt.
Yea I was planning on doing it. just got a little busy with personal life. I'll get around to it soon though and post any update in case anything comes up, because so far it was only showing Nuxt errors.
@danielroe I have tested it with the vue3-ssr-starter, same error is prompted, so it's either a vite or a vue issue. And although this question may sound silly, how do I choose to use webpack in stead of vite?
@GalacticHypernova In your config, change the builder to "@nuxt/webpack-builder" https://nuxt.com/docs/api/configuration/nuxt-config#builder
@Hebilicious thanks! Will check it out when I get home
Vite trusted type support is underway: https://github.com/vuejs/core/pull/10844
The PR I mentioned in the previous comment has been merged. I suppose the feature will be part of the upcoming Vue version 3.5.0
.
Environment
Build Modules: -
Reproduction
https://stackblitz.com/edit/github-rffaxj?file=pages%2Findex.vue
Start from the home page, click on the Nuxt link to Signup, and witness the TrustedHTML conflict.
https://imgur.com/a/SEDfi4V
As I will state in Additional context, since the issue only happens occasionally between certain routes (with this reproduction prompting the error most frequently), I have added a video of the issue happening in action following the steps I provided here for further proof in case it doesn't happen the first time with the stackblitz reproduction.
Describe the bug
When going to some pages, even ones that are completely static with no JavaScript in them, the above content security policy directive will conflict with (I guess?) Nuxt's internal way of setting innerHTML content, causing the page to not update when navigating between certain routes without a page reload.
Additional context
Despite it appearing like a router issue with vue (as it says in the logs that name and route are undefined) it only happens to SOME pages when adding the
require-trusted-types-for 'script'
directive.Logs