turnstile icon indicating copy to clipboard operation
turnstile copied to clipboard

400 bad request error when deployed with NuxtHub

Open pieterjanmaes opened this issue 1 year ago • 5 comments

📚 What are you trying to do?

Hi,

I want to use turnstile on a website I deploy with NuxtHub.

On my local host, everything works fine, but when I deploy with NuxtHub I always get

[nuxt] [request error] [unhandled] [400],[POST] "https://challenges.cloudflare.com/turnstile/v0/siteverify": 400 Bad Request I make use of the custom endpoint and helper method.

🔍 What have you tried?

The provided Nuxt Turnstile examples.

ℹ️ Additional context

Dependencies:

  • "@nuxt/scripts": "^0.10.1"
  • "@nuxtjs/turnstile": "^0.9.12"
  • "@nuxthub/core": "^0.8.16"
  • "nuxt": "^3.15.4",

pieterjanmaes avatar Feb 12 '25 16:02 pieterjanmaes

Same thing when deployed using Cloudflare pages. Route /_turnstile/validate returns error 500 and as a result my function fails with 400 Bad Request.

miagg avatar Mar 16 '25 18:03 miagg

I have this deployed on CF pages, same issue here - locally it all works fine. Any fixes?

BushidoDigital avatar Mar 28 '25 15:03 BushidoDigital

Did you ever get this resolved? I have the same issue.

Advistane avatar Jun 04 '25 01:06 Advistane

Did you ever get this resolved? I have the same issue.

Hi, I managed to solve this - turns out my Cloudflare setup wasn't respecting my nuxt config (from memory)

Adding my secretKey to my nuxt config solved it: secretKey: process.env.NUXT_TURNSTILE_SECRET_KEY

BushidoDigital avatar Jun 04 '25 19:06 BushidoDigital

secretKey: process.env.NUXT_TURNSTILE_SECRET_KEY

+1

vonec avatar Oct 20 '25 06:10 vonec