Skip to main content
Cloudflare Workers can provide a small server-side boundary close to your users. Store the Praxa key as an encrypted Worker secret, never as a plaintext configuration variable.

Prerequisites

Before you begin, prepare:
  • a trusted server runtime and application authentication boundary;
  • a disposable personal workspace Praxa key with only the tutorial’s required scopes;
  • synthetic input plus a persisted application request ID for replay tests;
  • a fake upstream for unit tests and a non-production environment for canaries;
  • an acceptance assertion that proves the Worker keeps the key secret, admits one task, and safely projects readback.

1. Declare and add the secret

wrangler.jsonc
For local development, use one ignored .dev.vars or .env file. Do not define the key under vars.

2. Implement the Worker

src/index.ts
Use Web Crypto in deterministicKey to hash an authenticated principal plus the stable application request ID. Do not trust an owner or workspace field in the body.

3. Test locally

Use a fetch interceptor or Miniflare to assert:
  1. Authentication runs before parsing or forwarding consequential work.
  2. Unknown methods and routes fail closed.
  3. Oversized input never reaches Praxa.
  4. Exact retries preserve the upstream idempotency key.
  5. The key never appears in the response, logs, or thrown errors.
  6. Every response carrying a run or problem is no-store.

4. Verify after deployment

Run two live canaries: an unauthenticated request that must fail before Praxa, and an authenticated disposable task that must return a run owned by the configured personal tenant. Follow the run to terminal before declaring the workflow complete.

Troubleshooting

Best practices

  • Store the key as a Worker secret, never a vars value.
  • Validate authentication and body size before upstream work.
  • Reuse one stable idempotency key per logical request.
  • Use explicit AbortSignal deadlines for upstream calls.
  • Rate-limit by the authenticated application principal.
  • Test locally with a fake upstream, then run a disposable deployed canary.

Cloudflare Workers secrets

Review the official secret-binding and local-development guidance.

Optimize for production

  • Reuse one configured HTTP or SDK client per process and bound concurrent upstream work.
  • Prefer durable admission plus asynchronous readback over holding application requests open.
  • Cache only non-sensitive, tenant-scoped reads within their documented freshness window.
  • Measure p50/p95 latency, admission-to-terminal time, retries, conflicts, and connection reuse before tuning.
Optimize only after the correctness and isolation matrix passes. Lower latency or cost is not an improvement if verified outcomes, authority checks, or recovery rates regress.

Cleanup and next steps

  1. Revoke the disposable Praxa key and require a later request to fail.
  2. Remove synthetic application records and any temporary environment files.
  3. Cancel or archive unresolved test runs according to the application policy.
  4. Retain only redacted request, run, and verification identifiers needed for the test record.
After cleanup, run the shared integration test matrix and record any environment-specific check that remains pending.

Frequently asked questions

What proves this tutorial works?

The minimum observable result is that the Worker keeps the key secret, admits one task, and safely projects readback. A compile, package import, mocked response, or initial admission alone does not prove the complete workflow.

Can a browser, mobile app, or model prompt hold the credential?

No. Browser and mobile bundles are inspectable. Keep the Praxa credential in the trusted application backend.

How should an ambiguous mutation be retried?

Persist the exact logical input and idempotency key before the first attempt. Reconcile through authoritative readback or replay the exact request with that same key before creating new work.

What should we monitor after release?

Monitor application auth failures, upstream status/code, latency, retries, replay conflicts, and terminal run outcomes. Alert on authorization bypass, cross-tenant disclosure, repeated conflicts, or cleanup failure.
Last modified on August 14, 2026