You can try running sample Cloudflare integration at https://botd.fingerprintjs.workers.dev/.
Login: human
, Password: iamnotbot
-
Create an account in Cloudflare.
-
Go to the
Workers
section and followset up the Wrangler CLI
.
Note: If Wrangler login
gets stuck in your console, try this method.
-
Rename
wrangler.toml.example
intowrangler.toml
. -
Fill in the parameter
name
- this is the name of the worker to be created. -
Fill in the parameter
account_id
- this can be found in the Cloudflare dashboard. -
Create the
CONFIG
namespace. You can learn more about namespaces in the Cloudflare documentation. Replace config binding inwrangler.toml
with the returned value.
wrangler kv:namespace create "CONFIG"
- 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 inwrangler.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"
- 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.
- [Optional] Analogically you can set the
botd_token
for your preview environment.
wrangler kv:key put --binding=CONFIG --preview "botd_token" "<your_botd_tokent>"
- 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>"
- [Optional] Analogically you can set the
botd_app
for your preview environment.
wrangler kv:key put --binding=CONFIG --preview "botd_app" "<origin_url>"
-
Run
npm install
-
[Optional] If you followed all the optional steps, you can run
wrangler dev
for local testing. -
Run
wrangler publish
to deploy worker.