Skip to content

Latest commit

 

History

History
24 lines (20 loc) · 1013 Bytes

add-cloudflare-durable-objects-to-environment.md

File metadata and controls

24 lines (20 loc) · 1013 Bytes
slug title type category_slug excerpt updated_at created_at
posts/add-cloudflare-durable-objects-to-environment
How to add Cloudflare Durable Objects to an environment
post
cloudflare
By default, Cloudflare's Durable Objects are not inherited across environments, here's how you can fix it.
2021-10-16
2021-10-16

For some reason, Cloudflare doesn't automatically inherit Durable Objects to environments like it does for the rest of the Worker settings. To get around this, you must define the Durable Objects for each environment. Here's an example using the default Counter example Worker:

# Default environment
[durable_objects]
bindings = [{name = "COUNTER", class_name = "CounterTs"}]

[env.staging]
name = "durable-objects-test-staging"

# Need to redefine the binding for the `staging` environment [tl! highlight:2]
[env.staging.durable_objects]
bindings = [{name = "COUNTER", class_name = "CounterTs"}]