Skip to content

Latest commit

 

History

History
79 lines (56 loc) · 2.97 KB

README.md

File metadata and controls

79 lines (56 loc) · 2.97 KB

Cloudflare Botd integration

Sample integration

image You can try running sample Cloudflare integration at https://botd.fingerprintjs.workers.dev/.

Login: human, Password: iamnotbot

Setting up the integration

  1. Create an account in Cloudflare.

  2. Go to the Workers section and follow set up the Wrangler CLI.

Note: If Wrangler login gets stuck in your console, try this method.

  1. Rename wrangler.toml.example into wrangler.toml.

  2. Fill in the parameter name - this is the name of the worker to be created.

  3. Fill in the parameter account_id - this can be found in the Cloudflare dashboard.

  4. Create the CONFIG namespace. You can learn more about namespaces in the Cloudflare documentation. Replace config binding in wrangler.toml with the returned value.

wrangler kv:namespace create "CONFIG"
  1. Create a preview namespace for the existing CONFIG namespace. Preview namespaces are used for interacting with preview instead of the production environment. This environment is also used for local development. Add returned value to config binding in wrangler.toml
wrangler kv:namespace create "CONFIG" --preview

Your wrangler.toml should look like:

name = "<your_integration_name>"
type = "javascript"

account_id = "<your_account_id>"
workers_dev = true
route = ""
zone_id = ""

kv_namespaces = [
    { binding = "CONFIG", preview_id = "<generated_returned_preview_id_by_wrangler_cli>", id = "<generated_returned_preview_id_by_wrangler_cli>" }
]

[build]
command = "npm install && npm run build"
[build.upload]
format = "service-worker"
  1. Put botd_token key-value pair to already created namespace, botd_token is an authorization token obtained from FingerprintJS.
wrangler kv:key put --binding=CONFIG "botd_token" "<your_botd_tokent>"

Note: After publishing your worker, you can view and edit your key-value pairs in the KV section of the crawler in Cloudflare's UI.

  1. [Optional] Analogically you can set the botd_token for your preview environment.
wrangler kv:key put --binding=CONFIG --preview "botd_token" "<your_botd_tokent>"
  1. Put botd_app key-value pair to already created namespace, botd_app is the origin backend URL.
wrangler kv:key put --binding=CONFIG "botd_app" "<origin_url>"
  1. [Optional] Analogically you can set the botd_app for your preview environment.
wrangler kv:key put --binding=CONFIG --preview "botd_app" "<origin_url>"
  1. Run npm install

  2. [Optional] If you followed all the optional steps, you can run wrangler dev for local testing.

  3. Run wrangler publish to deploy worker.