turnstile icon indicating copy to clipboard operation
turnstile copied to clipboard

TurnstileError: [Cloudflare Turnstile] Invalid type for parameter "container", expected "string" or an implementation of "HTMLElement".

Open WuChenDi opened this issue 1 year ago â€ĸ 2 comments

🐛 The bug

Hello everyone, I apologize for the interruption.

I have a question: I encountered no issues using Turnstile in my frontend project.

However, when I use it on another page, I experience the following error during page transitions.

For instance, when both app/pages/login.vue and app/pages/signup.vue utilize the NuxtTurnstile component, the subsequent error arises. In the development environment, the page appears blank, while in the deployed version, the page displays correctly but fails to show the verification widget.

VM113320 api.js:1 Uncaught (in promise) TurnstileError: [Cloudflare Turnstile] Invalid type for parameter "container", expected "string" or an implementation of "HTMLElement".

image

đŸ› ī¸ To reproduce

https://github.com/cdLab996/turnstile-examples-nuxt

🌈 Expected behaviour

It is anticipated to be displayed correctly across multiple pages.

image

â„šī¸ Additional context

No response

WuChenDi avatar Sep 25 '24 03:09 WuChenDi

UP. Just came to report this. since latest version

moshetanzer avatar Sep 26 '24 07:09 moshetanzer

This is my current approach.

However, I am aware that it is not the most effective method.

https://github.com/cdLab996/turnstile-examples-nuxt/commit/1aac4e17cb143ac723c3616566a838a83c11fbdf

WuChenDi avatar Sep 29 '24 10:09 WuChenDi

Is there any update about this? We're facing the same issue on our project.

onurgultekin avatar Oct 11 '24 18:10 onurgultekin

@danielroe it appears that just using onLoaded leads to this issue. On route change onLoaded seems to called before the element to mount into is available (as it's not mounted?). Does that sound plausible to you or should onLoaded not be the issue?

Edit: ah, I think onLoaded is called again because remove is called on unmount. I guess it makes sense to remove on unmount? So then I'd say onMounted would need to be used again.

dargmuesli avatar Oct 13 '24 23:10 dargmuesli

I've created PR https://github.com/nuxt-modules/turnstile/pull/344 for now until it is determined what the proper solution should look like (maybe it already is the proper solution). You should be able to install v0.9.11-beta.1 to check this fix.

dargmuesli avatar Oct 14 '24 00:10 dargmuesli

Thanks dargmuesli I will try it out now.

onurgultekin avatar Oct 14 '24 06:10 onurgultekin

dargmuesli it seems fixed. Thanks!

onurgultekin avatar Oct 14 '24 07:10 onurgultekin

Still goin on, @dargmuesli thanks for temporarily fix.

arshx86 avatar Nov 01 '24 19:11 arshx86

:tada: This issue has been resolved in version 0.9.11 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

dargmuesli-bot avatar Nov 05 '24 23:11 dargmuesli-bot