{"id":19521013,"url":"https://github.com/rodneylab/hcaptcha-serverless-rust-worker","last_synced_at":"2025-10-12T02:53:53.406Z","repository":{"id":41951291,"uuid":"409255396","full_name":"rodneylab/hcaptcha-serverless-rust-worker","owner":"rodneylab","description":"Demo code for creating an hCaptcha verify endpoint using Cloudflare Workers written in Rust","archived":false,"fork":false,"pushed_at":"2022-04-25T10:44:35.000Z","size":118,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-26T00:28:45.612Z","etag":null,"topics":["cloudflare-workers","hcaptcha","rust","serverless","wasm"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rodneylab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE_APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null}},"created_at":"2021-09-22T15:21:03.000Z","updated_at":"2024-03-01T09:51:05.000Z","dependencies_parsed_at":"2022-08-12T00:22:37.055Z","dependency_job_id":null,"html_url":"https://github.com/rodneylab/hcaptcha-serverless-rust-worker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rodneylab/hcaptcha-serverless-rust-worker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodneylab%2Fhcaptcha-serverless-rust-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodneylab%2Fhcaptcha-serverless-rust-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodneylab%2Fhcaptcha-serverless-rust-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodneylab%2Fhcaptcha-serverless-rust-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rodneylab","download_url":"https://codeload.github.com/rodneylab/hcaptcha-serverless-rust-worker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodneylab%2Fhcaptcha-serverless-rust-worker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009973,"owners_count":26084672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare-workers","hcaptcha","rust","serverless","wasm"],"created_at":"2024-11-11T00:28:50.421Z","updated_at":"2025-10-12T02:53:53.391Z","avatar_url":"https://github.com/rodneylab.png","language":"Rust","readme":"\u003cimg src=\"./images/rodneylab-github-hcaptcha-serverless-rust-worker.png\" alt=\"Rodney Lab hcaptcha-serverless-rust-worker Github banner\"\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca aria-label=\"Open Rodney Lab site\" href=\"https://rodneylab.com\" rel=\"nofollow noopener noreferrer\"\u003e\n    \u003cimg alt=\"Rodney Lab logo\" src=\"https://rodneylab.com/assets/icon.png\" width=\"60\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003e\n  hCaptcha Serverless Rust Worker\n\u003c/h1\u003e\n\n# hcaptcha-serverless-rust-worker\n\n[![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/rodneylab/hcaptcha-serverless-rust-worker)\n\n**Cloudflare Worker written in Rust to create an hCaptcha verification endpoint.**\n\nTo learn how to code this up from scratch in Rust using wrangler, see the \u003ca aria-label=\"Open Rodney Lab blog post on using Rust Cloud flare Workers\" href=\"https://rodneylab.com/using-rust-cloudflare-workers/\"\u003earticle on using Rust in serverless Cloudflare workers\u003c/a\u003e. If you have any questions, please drop a comment at the bottom of that page.\n\nIf you would like to use the Worker read on!\n\nYou will need a Cloudflare account as well as an hCaptcha account.  Both services have a free tier.\n\n1. Start by cloning this repo:\n\n    ```shell\n    git clone https://github.com/rodneylab/hcaptcha-serverless-rust-worker\n    cd hcaptcha-serverless-rust-worker\n    ```\n\n1. Continue by \u003ca aria-label=\"Create a Cloudflare account\" href=\"https://dash.cloudflare.com/sign-up\"\u003esetting up a Cloudflare account\u003c/a\u003e if you do not yet have one.\n\n1. Now \u003ca aria-label=\"Visit the h captcha site to create an account\" href=\"https://www.hcaptcha.com/\"\u003ecreate an hCaptcha account\u003c/a\u003e, if you don't yet have one.\n\n1. If you do not yet have a Rust development environment set up on your machine,  \u003ca aria-label=\"See recommended rust up installation instructions\" href=\"https://www.rust-lang.org/tools/install\"\u003ehead over to the official Rust site for the recommended one-line terminal command\u003c/a\u003e to get that up and running.\n\n1. Install the wrangler tool on your machine:\n\n    ```shell\n    cargo install wrangler\n    ```\n\n1. Next link your Cloudflare account to your local environment:\n\n    ```shell\n    wrangler login\n    ```\n\n1. Now we will define some variables.  Start with your hCaptcha site key (get this from the hCaptcha dashboard):\n\n    ```\n    wrangler secret put HCAPTCHA_SITEKEY\n    ```\n\n    paste in your site key when prompted.\n\n1. Repeat with your hCaptcha secret key\n\n    ```\n    wrangler secret put HCAPTCHA_SECRETKEY\n    ```\n\n1. Finally we will define the CORS origins.  This is a comma separated list of valid domains you want to be able to send requests from (typically your live client site and a local development site).  If you have the the following domains:\n\n    - https://www.example.com,\n    - http://127.0.0.1:3000,\n\n\n    Enter the secret as `https://www.example.com,http://127.0.0.1:3000` when prompted.\n    \n    Let's define this now then:\n\n    ```\n    wrangler secret put CORS_ORIGIN\n    ```\n\nThat should be everything set up.\n\n## Testing \n1. Now fire up the dev server for testing:\n\n    ```\n    wrangler dev\n    ```\n\n    By default the worker will be available locally at `http://127.0.0.1:8787`.\n\n1. Now you need to generate an hCaptcha request from a client app and send it to `http://127.0.0.1:8787/verify` as JSON, using the  `POST` method.  If you are working in JavaScript, you might code this up something like this:\n\n```javascript\n  async function handleVerify() {\n    try {\n      if (browser) {\n        const { response } = await hcaptcha.execute(hcaptchaWidgetID, {\n          async: true,\n        });\n        const responsePromise = fetch(`${workerUrl}/verify`, {\n          method: 'POST',\n          credentials: 'omit',\n          headers: {\n            'Content-Type': 'application/json',\n          },\n          body: JSON.stringify({\n            response,\n          }),\n        });\n      }\n    } catch (error) {\n      console.error(`Error in handleVerify: ${error}`);\n    }\n  }\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodneylab%2Fhcaptcha-serverless-rust-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodneylab%2Fhcaptcha-serverless-rust-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodneylab%2Fhcaptcha-serverless-rust-worker/lists"}