nuxt-modules / turnstile

๐Ÿ”ฅ Cloudflare Turnstile integration for Nuxt
https://cloudflare.com/products/turnstile
MIT License
230 stars 18 forks source link

Turnstile disabled during Nuxt3 app build due to empty siteKey #236

Closed vanling closed 1 year ago

vanling commented 1 year ago

๐Ÿ› The bug

Turnstile disabled during Nuxt3 app build on Jenkins due to empty siteKey configuration value

During the build, Turnstile gets disabled due to empty values in the config options, as indicated by the warning message: WARN @nuxtjs/turnstile is disabled as no site key was provided.

๐Ÿ› ๏ธ To reproduce

๐ŸŒˆ Expected behaviour

Turnstile should not be disabled during the build process, since the environment variables for site key and secret key can be set at runtime.

โ„น๏ธ Additional context

The issue occurs when building Nuxt3 applications with Turnstile integration externally of where the .output of nuxt is run. The environment variables NUXT_TURNSTILE_SECRET_KEY and NUXT_PUBLIC_TURNSTILE_SITE_KEY are used at runtime to replace the empty values in the config options siteKey and secretKey.

Currently saving random strings in the config to make sure its not getting disabled during build and overwrite the random strings during runtime.

danielroe commented 1 year ago

Now released in 0.4.0. Let me know if all is working for you.

vanling commented 1 year ago

@danielroe seems to be working :D thank you.

[info] Using html-validate to validate server-rendered HTML
[info] [nuxt:tailwindcss] Using default Tailwind CSS file from runtime/tailwind.css
[warn] [turnstile] No site key was provided. Make sure you pass one at runtime by setting NUXT_PUBLIC_TURNSTILE_SITE_KEY.
[log] โœ” Router autocompletions generated ๐Ÿšฆ
image