I’m working with the new environment variables that come with the new icp-cli. I have deployed an asset canister, and set the backend canister id with the management canister. However, when I deploy and load the frontend (boilerplate from icp new) it says: index-CoCUfho5.js:58 Uncaught InputError: Canister ID is required, but received undefined instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly. And when I inspect the request the response does not include the backend canister id environment variable. However, when I call the management canister it returns the backend canister as an environment variable.
Figured it out in case anyone else runs into same problem:
The asset canister bakes PUBLIC_* env vars into the ic_env cookie during
commit_batch (inside sync_assets). Previously update_settings was called
AFTER sync_assets, so the cookie only contained the root key.
Just to clarify: if you’re using icp deploy as a single command, the correct ordering (env vars before asset sync) is already handled automatically by the CLI — so the manual 3-phase workaround shouldn’t be necessary.
I am struggling a bit to understand how you were running into the issue, especially if you created the project from a template via icp new.
Did you run icp deploy end-to-end, or were you invoking individual steps in a custom order?
I’m working on a PaaS that lets you link github repo and auto deploys. Initially I was doing the steps manually, not using icp-cli, and that is when I ran into the issue. I’ve since switched to using the icp-cli for everything.