nuxt-modules / turnstile

🔥 Cloudflare Turnstile integration for Nuxt
https://cloudflare.com/products/turnstile
MIT License
215 stars 17 forks source link

fix: prefer #app useHead #271

Closed huang-julien closed 10 months ago

huang-julien commented 10 months ago

Hi :wave: This PR resolve #250

I've been able to reproduce the issue within the playground as stated in a comment.

⚠️ However, i do have a website which is currently in production with nuxt 3.6.5 WITHOUT this issue which makes me quite nervous if it reveals that the issue only happens for a small fractions of users.

So I noticed that useHead() could not injectHead() within the turnstile plugin. Switching the useHead() from #app seems to fix the issue locally for me.

Another note is that useHead from #app and useHead from #imports are not equal, even the body is different.

image

(maybe is it a nuxt treeshaking or deps optimization issue ?)

Since this issue is quite bizarre, i have no idea on how to reproduce it on e2e tests.

cc @harlan-zw

codecov[bot] commented 10 months ago

Codecov Report

Merging #271 (77baf3d) into main (aafeb91) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #271   +/-   ##
=======================================
  Coverage   82.60%   82.60%           
=======================================
  Files           2        2           
  Lines         115      115           
  Branches       13       13           
=======================================
  Hits           95       95           
  Misses         20       20           

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

harlan-zw commented 10 months ago

This is quite bizarre and worth investigating further, thanks for your efforts!

danielroe commented 10 months ago

I'm not sure this is the right solution. useHead from #app is deprecated. It looks like this is a bug in unhead or Nuxt which we need to resolve. Reverting on main; we can keep released version as a workaround for now.