Siyali Gupta

Siyali Gupta started this conversation 9 months ago.

0

1

aws

Is it possible to run Cloudflare Turnstile on preview deployments with autogenerated domains?

"Is it feasible to implement Cloudflare Turnstile on preview deployments that utilize autogenerated domains, and if so, what are the necessary steps and configurations required to ensure it functions correctly?"

codecool

Posted 9 months ago

Yes, it is possible to run Cloudflare Turnstile on preview deployments with autogenerated domains! Here are the necessary steps and configurations to ensure it functions correctly:

Deploy Your Project:

Log in to the Cloudflare Dashboard and select your account.

Go to Workers & Pages and create a new Pages application with your git provider.

Choose the repository where you want to deploy your project.

Configure Build Settings:

Set the framework preset to None.

Use the build command: npm install @cloudflare/pages-plugin-turnstile.

Set the build output directory to public.

Embed the Turnstile Widget:

Navigate to the Turnstile settings and add your Pages application domain.

Cloudflare Pages generates a unique preview subdomain for each deployment.

Turnstile covers all subdomains automatically, so the widget will work as expected even in preview deployments.

Enable Access Policy (Optional):

If you want to restrict access to your preview deployments, go to Settings > General and enable the access policy.

This will protect your preview deployments and allow you to set up multi-user accounts for team members.