Can service bindings be tested locally with wrangler dev?

I have two workers setup locally, but clearly when you call wrangler dev, it’s only going to start one of the workers. So if that worker has a service binding, how do you get both up and running locally? Or do we need some kind of a localhost mock for our binding?

Kinda. You’ll need wrangler 2, and this in your wrangler.toml:

binding = "MYWORKER"
service = "my-worker"
environment = "production"

But it has some limitations. See feat: implement support for service bindings by threepointone · Pull Request #906 · cloudflare/wrangler2 · GitHub for more info.

Ok, so it connects to the production environment of the service. To me, that seems exceptionally dangerous. To the point that I’m not sure I’d ever want to do that. Instead, I’m going to mock the service on localhost.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.