I'm developing a website using PHP and I want to make a human verification in one of the sessions. For the development, I'm initially running the system locally and when it is ready, I'm gonna make put it on in a certain domain.
In the reCAPTCHA website it is said that the plugin will only work at the given domain (and subdomains).
My question is: Is there any way to use the reCAPTCHA plugin on a localhost?
I was recently working on creating a website involving recaptcha v2 and I have a need to do test automation on my localhost. I did not add any ip or localhost into recaptcha admin portal.
Follow the below steps
Log in to recaptcha admin site screenshot
Locate Key Settings
Click on advanced settings
Under Domain Name Validation, un-check Verify the origin of reCAPTCHA solutions checkbox. This option is used to verifying requests come from one of the above listed domains.
Please note that, If disabled, you are required to check the host-name on your server when verifying a solution.
I created a new key and disable this and use this key for testing in localhost.
This is a sample page which implements reCAPTCHA for comments.
It's so easy:
localhost
&127.0.0.1
to domains of a new site like the following image.Update:
If your question is how to set
reCaptcha
in Google site for using it in localhost, then i has been wrote it above but if you are curious that how you can usingreCAPTCHA
on bothlocalhost
andwebsite host
by minimal codes in your controller and prevent some codes likeConfigurationManager.AppSettings["ReCaptcha:SiteKey"]
in it then I help you with this extra description and codes in my answer.Do you like the following GET and POST actions?
Google has recently changed stopped allowing localhost being allowed by default. (as touched upon by @Artur Cesar De Melo)This is under their FAQ's:
1: Create a separate key for your development environment
2: Add 127.0.0.1 to the list of allowed domains
3: Save changes and allow up to 30 mins for changes to take affect
As per Google recaptcha documentation
Please note that as of 2016, ReCaptcha doesn't naively support localhost anymore. From the FAQ:
So just add
localhost
to your list of domains for your site and you'll be good.