Bind Your Own D1 and KV: Never Copy an Id
Cloudflare binds D1 and KV by id and never checks the name. A copied id attaches your app to another project's data, and every query succeeds.
Deployment
Pages, Workers, D1, KV and Durable Objects: the limits, the traps, and the guards that catch them
10 guides in this collection
Cloudflare binds D1 and KV by id and never checks the name. A copied id attaches your app to another project's data, and every query succeeds.
D1 records applied migrations by file name. Editing an old file changes only new databases, so enforce never-edit and one-number-per-file with a script.
Pages runs one build command for every branch. If that command applies migrations, each pull request preview tries to change the live database.
Pages has no Cron Triggers. Run a small Worker that calls authenticated routes, claim each run in one SQL statement, and test that the pieces agree.
The limits that stop a Cloudflare app are daily counts of KV writes and D1 rows. Keep volatile state out of synced storage, and give every loop a per-run cost.
A Durable Object can be evicted while its WebSockets stay open. Rebuild state from the sockets, not from memory, and delete the alarm before the storage.
Pin the dev port, bind to loopback, allow the tunnel host in Vite, and check the public URL from outside before you say it works.
Pages serves static files without running your code. Set headers in the server hook and again in _headers, and test that the two lists match.
Workers rejects PBKDF2 above 100,000 iterations. Code that uses more passes every local test and returns a 500 for every sign-in in production.
An ISO string from JavaScript and datetime('now') from SQLite are different text formats. Compared directly, an expired session stays valid until the end of the day.