Rather than having the client route the requests to the correct server, would it not be better to write a custom API server that takes a JSON API call and proxies the call to the right JSON API server?
/----- [JSON API server A]
[frontend] ------- [API server] ------ [JSON API server B]
\----- [JSON API server C]
The proxy server would need to:
- Extract the DAML party from the request. This can be either done by inspecting the JWT token, or the DAML React Component could be extended to include a custom HTTP header for this.
- Know what participant each party is hosted on.
- Proxy the call to the right JSON API server. I’m sure each language has libraries to do so easily. Node.js has express-http-proxy, for example.
This also sounds similar to Running multiple instances of create-daml-app simultaneously against multiple participants. @Phoebe_Nichols, how did you solve this for your “run create-daml-app on Canton” tutorial?