Closed
Description
Currently, running dfx start
will start a replica-ish executable that will proxy HTTP requests to installed canisters based on the value of ?canisterId=...
. This is not ideal for the following reasons:
- The canister IDs are dynamic and not generally known before the canisters are installed. This means that if I have another local service (think: e2e tests) that needs to connect to a given canister, I need to always update the URL to connect to. While canister IDs seem to be always assigned in the same order, this is not documented nor is it robust, and breaks if I don't start from a clean state (e.g. with no canisters installed).
- The query parameters need to be forwarded to all calls. This is an issue if I have e.g. a multi page webapp that performs redirects. For instance, the webapp may re-route to
/
when the user logs out, which will break because of the missing?canisterId=...
.
In the nns-dapp we are working around this by using a proxy that maps (stable, known) ports to canister -- by name. In particular, our end-to-end test runner will start by looking up the canister IDs in .dfx/local/canister_ids.json
and the replica host in dfx.json
and will then route requests appropriately. The test suite can then use localhost:<stable port>
to reach a given canister. It would be great to have something similar baked into dfx
as opposed to using query parameters.
Metadata
Metadata
Assignees
Labels
No labels