6

How can I test hCaptcha on localhost?

When using the key, I get a CORS error, and for choosing sites for the key, it specifically states ... localhost will not work

Kevin Danikowski
  • 4,620
  • 6
  • 41
  • 75

2 Answers2

10

There are test keys you should use for testing, see https://docs.hcaptcha.com/#integration-testing-test-keys

Referenced Below:

Test Key Set: Publisher Account

Test parameter Value

Site Key 10000000-ffff-ffff-ffff-000000000001 Secret Key 0x0000000000000000000000000000000000000000

Test Key Set: Enterprise Account (Safe End User)

Test parameter Value

Site Key 20000000-ffff-ffff-ffff-000000000002 Secret Key 0x0000000000000000000000000000000000000000

Test Key Set: Enterprise Account (Bot Detected)

Test parameter Value

Site Key 30000000-ffff-ffff-ffff-000000000003 Secret Key 0x0000000000000000000000000000000000000000

PS: I confirmed this with the hCaptcha team.

PSS: A different work around would be use change your hosts file to point your-website.com to localhost to do testing.

Kevin Danikowski
  • 4,620
  • 6
  • 41
  • 75
  • 1
    i'm running into the same problem... how am i supposed to embed the hcaptcha into my site, if i can never see if it actually works, if challenges are shown properly etc? how will "keys that always generate a passcode without asking a question" help me with that? – devman Jul 21 '21 at 13:37
  • 2
    @devman a work around is to just change your `hosts` file to point `your-website.com` to localhost. – Kevin Danikowski Jul 21 '21 at 13:47
6

in the browser replace localhost to 127.0.0.1

https://i.stack.imgur.com/tDsPW.png