You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These will not work in local development, but they should work in production.
229
-
229
+
230
230
If you want to develop these locally, you can define your DO "externally" in another Worker.
231
-
To do this, create another Worker, e.g.
232
-
233
-
export class MyDurableObject extends DurableObject {
234
-
// DO code goes here
235
-
}
236
-
export default {
237
-
fetch() {
238
-
// doesn't have to do anything, but DO cannot be the default export
239
-
}
240
-
}
241
-
242
-
Also create a new Wrangler config file for this Worker, e.g.
243
-
244
-
{
245
-
"name": "external-do-worker",
246
-
"main": "src/index.ts",
247
-
"compatibility_date": "XXXX-XX-XX"
248
-
}
249
-
250
-
Then, update your original DO bindings to include the script_name field, e.g.
251
-
{
252
-
"durable_objects": {
253
-
"bindings": [
254
-
{
255
-
"name": "BINDING",
256
-
"class_name": "MyDurableObject",
257
-
"script_name": "external-do-worker"
258
-
}
259
-
]
260
-
}
261
-
}
262
-
263
-
You will be able to develop this locally by running:
264
-
npx wrangler dev -c path/to/original/wrangler.jsonc -c path/to/external-do/wrangler.jsonc
231
+
Refer to [4mhttps://developers.cloudflare.com/durable-objects/platform/known-issues/#local-development-with-web-frameworks[0m for guidance on how to do this.
Then, update your original DO bindings to include the script_name field, e.g.
170
-
${formatConfigSnippet(
171
-
{
172
-
durable_objects: {
173
-
bindings: [
174
-
{
175
-
name: "BINDING",
176
-
class_name: "MyDurableObject",
177
-
script_name: "external-do-worker",
178
-
},
179
-
],
180
-
},
181
-
},
182
-
configPath
183
-
)}
184
-
185
-
You will be able to develop this locally by running:
186
-
npx wrangler dev -c path/to/original/wrangler.jsonc -c path/to/external-do/wrangler.jsonc
152
+
Refer to https://developers.cloudflare.com/durable-objects/platform/known-issues/#local-development-with-web-frameworks for guidance on how to do this.
0 commit comments