Turnsite CSP violation, how to fix?

What is the name of the domain?

https://dash.cloudflare.com/login

What is the error message?

Refused to run the JavaScript URL because it violates the following Content Security Policy directive: “script-src ‘nonce-’ ‘unsafe-eval’”. Either the ‘unsafe-inline’ keyword, a hash (‘sha256-…’), or a nonce (‘nonce-…’) is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the ‘unsafe-hashes’ keyword is present.

What is the issue you’re encountering

Is it even possible to implement Turnstile without all of these errors?

What steps have you taken to resolve the issue?

I have tried, while implementing this on my side, every possible permutation of Content Security Policy, however nothing works. Started trying to find a working example only to realise that everyone has the same issue including cloudflare’s own site?! The documentation seems to imply this is an easy fix: Content Security Policy · Cloudflare Turnstile docs

What are the steps to reproduce the issue?

Try and implement the product, apparently.

Screenshot of the error

4 Likes

I’m also facing the same issue and every CSP related setting doesn’t seem to do anything. In this doc there is note about using nonce if you run into this issue, however even nonce doesn’t fix the issue.

3 Likes

Same here - this error is also showing on the Cloudflare login page on Turnstile so I suspect this issue is on your end.

I’m also experiencing this issue on sites that I manage using Turnstile, please advise…

Same issue here, I tried adding the nonce and everything. It doesn’t seem to help. We’re using Nextjs (Configuring: Content Security Policy | Next.js)

We are experiencing this issue too. Seems like the cloudflare-script https://challenges.cloudflare.com/cdn-cgi/challenge-platform/h/b/orchestrate/chl_api/v1?ray=SOMEHASH&lang=auto wants to execute some inline javascript on cross domain which is not supported by default in the browser. I tried to add a CSP-header to allow cross-domain inline-script execution for cloudflare, but it didn’t solve the issue.

1 Like

I am also facing this issue. It seems to work fine on iOS and Windows/Linux desktops (Brave, Safari, Edge, Chrome).

However it seems that the Turnstile token is being generated on my page after 20-30s for Androids, which then would allow the Android user to finally submit the form.

1 Like

We are also experiencing this issue on multiple sites, and can confirm that adding nonce does not fix this.

1 Like

I’m also seeing this issue on a React Native web build running within a Next.js app. Updating CSP headers didn’t seem to help.

Also seeing this error. I’m experiencing this issue on my project as well, even after trying to update the CSP headers and adding a nonce. Has anyone found a workaround or an official fix from Cloudflare? Any insights would be helpful.

I also have this error. I am using nonces within my project with ‘strict-dynamic’ policy. I believe cloudflare script is adding javascript URL (Example - javascript:alert(‘’)) and this is forbidden by the CSP. My captcha seems to work

Cloudflare turnstile captcha stopped working on my website too. I can’t pass it, its either spinning infinitely by itself or after the click not resolving and stuck with the message - “Stuck here” submit feedback, here is rayid of the example: Ray ID: 919164f539d772ab

Same issue for me. Does anyone have an update from Cloudflare about this issue? These posts seem to be getting ignored.

1 Like

FWIW, Cloudflare staff are discussing an issue that I think has the same cause here: Turnstile Safari errors - #8 by mdemoura

1 Like

Same error solved , using right init way.

Solution is init call , and window check for avoid double import and proper destroy

Any chance you could post the code that was key to solving this?

1 Like

Yes! I’ve tested all edge cases, and everything is now working perfectly.

At the moment, there are zero console issues, except for Google’s document.write notice, which isn’t affecting functionality.

Could you share your code or describe the specific use case you’re facing?
I’m finalizing a complete WordPress solution for Elementor, popups, and multiple Turnstile instances on the same page. This will be published on GitHub soon, so any additional insights would be great to refine it further.

Looking forward to your feedback!

Could you share an example of the bug? A GitHub repo or CodePen would be helpful.

I also encountered this problem. Cloudflare officials seem to need to update their js code.