dbcn
dbcn

Reputation: 248

How to generate different recaptcha API keys for subdomain?

We'd like to have separate reCaptcha API keys for our development and production environments, but the development site is a subdomain of the production site:

www.mysite.com

dev.mysite.com

From the Google docs, it looks like as soon as we add mysite.com to the captcha domain list, it will use the same API key for all subdomains - is it possible to use set up different API keys for a subdomain?

Upvotes: 5

Views: 6728

Answers (2)

Zupecki
Zupecki

Reputation: 66

It's all to do with what keys you deploy with.

So create x sets of keys, and label them like 'dev', 'test', 'prod', 'whatever'.

Have them all linked to the mysite.com

Then when you deploy your application, in each subdomain environment, just load the keys for each and then you'll have separate metrics.

Works for us!

Upvotes: 2

dbcn
dbcn

Reputation: 248

I was not able to get a subdomain separated out to use a different API key, but Google does provide a sandbox Site Key/Secret pair that can be used to test the recaptcha and not clutter up productions analytics. It's set to always return a valid response, but you can easily modify that response within the application as failed for testing. Test recaptcha key & secret can be found at:

https://developers.google.com/recaptcha/docs/faq

Upvotes: 3

Related Questions