diff --git a/hello-world/react-frontend/src/App.tsx b/hello-world/react-frontend/src/App.tsx index e8813a0..b648a0c 100644 --- a/hello-world/react-frontend/src/App.tsx +++ b/hello-world/react-frontend/src/App.tsx @@ -12,15 +12,17 @@ interface CanisterEnv { } // We only want to access the environment variables when serving the frontend from the asset canister. -// In development mode, we use a fixed canister ID for the backend canister. +// `getCanisterEnv` will retrieve the environment variables and the root key from the cookie returned +// by the asset canister. +// When developing locally, the Vite server will inject the cookie into the responses. +// See vite.config.ts. const canisterEnv = getCanisterEnv(); const canisterId = canisterEnv["PUBLIC_CANISTER_ID:backend"]; -// We want to fetch the root key from the replica when developing locally. +// We always use the root key that is coming back from the cookie in the asset canister const helloWorldActor = createActor(canisterId, { agentOptions: { - rootKey: !import.meta.env.DEV ? canisterEnv!.IC_ROOT_KEY : undefined, - shouldFetchRootKey: import.meta.env.DEV, + rootKey: canisterEnv.IC_ROOT_KEY, }, }); diff --git a/hello-world/vue-frontend/src/App.vue b/hello-world/vue-frontend/src/App.vue index 5841879..042cf51 100644 --- a/hello-world/vue-frontend/src/App.vue +++ b/hello-world/vue-frontend/src/App.vue @@ -1,12 +1,26 @@ -