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
.dev.vars or
.env file. Do not define the key under vars.
2. Implement the Worker
src/index.ts
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:- Authentication runs before parsing or forwarding consequential work.
- Unknown methods and routes fail closed.
- Oversized input never reaches Praxa.
- Exact retries preserve the upstream idempotency key.
- The key never appears in the response, logs, or thrown errors.
- 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
varsvalue. - Validate authentication and body size before upstream work.
- Reuse one stable idempotency key per logical request.
- Use explicit
AbortSignaldeadlines 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.
Cleanup and next steps
- Revoke the disposable Praxa key and require a later request to fail.
- Remove synthetic application records and any temporary environment files.
- Cancel or archive unresolved test runs according to the application policy.
- Retain only redacted request, run, and verification identifiers needed for the test record.