-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NuxtTurnstile component not loading Turnstile script as expected #250
Comments
Would you mind adding a reproduction using stackblitz? 🙏 |
|
Reopening, see #271 (comment) |
I am also facing same issue, it is giving error on manual refresh but with router changes it is working fine |
I have tried this and it works until this issue not getting resolved
|
Using it on my nuxt 3 project. Works fine on SSR but if I navigate to the page that contains turnstile from another page via SPA then it fails. my solution is using <a href instead of <nuxt-link only for the pages that containing turnstile. that way you will never experience this issue on such cases. |
I'm facing the same issue, that the component is not loading when I completely reload the page (no SSR). But the solution from @ajaythakkar works so far as a workaround. <NuxtTurnstile v-if="loadTurnstile" v-model="token" />
...
const loadTurnstile = ref(false);
onMounted(() => {
setTimeout(() => {
loadTurnstile.value = true;
}, 500);
}); |
I've just faced the same issue and resolved it this way (less random than waiting 500ms): const pageReady: Ref<boolean> = ref(false);
onNuxtReady(() => {
pageReady.value = true;
}); |
@harlan-zw this sounds like a use case for turnstile/src/runtime/plugins/script.ts Line 97 in 8cfdd9f
cc @danielroe |
See #306 |
Ahh, that's where I saw that! 🙈 confused it with another repo 😄 Great work 💪 |
🐛 The bug
While using the NuxtTurnstile component from the nuxt turnstile package, it seems that the Turnstile script isn't loading as expected, throwing an Uncaught TypeError: Cannot read properties of undefined (reading 'render') error.
The problem is here according to the console.
script.mjs?v=be5efb17:33 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'render')
at Object.render (script.mjs?v=be5efb17:33:31)
line:
return window.turnstile.render(element, {
When loading in the cdn script through useHead and using onMounted to wait for when the script is available makes it work. But then the script is loaded 2 times. Resulting in a lot of other undesired behaviour.
Maybe you can add in your code to wait for window.turnstile?
🛠️ To reproduce
.
🌈 Expected behaviour
That window.turnstile is available before use.
ℹ️ Additional context
No response
The text was updated successfully, but these errors were encountered: