How to test two binding workers in dev environment?

I have 2 workers, one of which needs to call the fetch result of the other worker. I understand that we can modify the services binding in wrangler.toml to enable two workers to call each other. But if I don’t want to deploy and just want to test the modification results locally (wrangler dev), is there a more convenient method? For Example: worker A: services = [ { binding = "WORKER_B", service = "worker_b" } ] I run wrangler dev in worker_b Can I use fetch method in work_A to get result from work_B? If I can't use fetch, what method can I use?
2 Replies
oof2win2
oof2win28mo ago
you run wrangler dev in both directories assuming its the same instance of wrangler (say installed globally) it will auto connect
Vlady
Vlady7mo ago
Hey folks, is there a way to explicitly point to the port of the other instance of wrangler? I'm trying to proxy a local API worker from a pages, but getting this error
[wrangler] Couldn't find `wrangler dev` session for service "yupty-api" to proxy to
[wrangler] Couldn't find `wrangler dev` session for service "yupty-api" to proxy to
My pages project config:
name = "front"
dev.port = 3000
services = [
{ binding = "API", service = "yupty-api" }
]
name = "front"
dev.port = 3000
services = [
{ binding = "API", service = "yupty-api" }
]
My API project config:
name = "yupty-api"
dev.port = 3010
name = "yupty-api"
dev.port = 3010
I restarted my computer and it found the other worker 🤷🏼‍♂️ ✅
Want results from more Discord servers?
Add your server