Creating a web canister

The error remained.

There’s one more place where this is called: https://github.com/fury02/rbac-motoko/blob/main/src/declarations/rbac/index.js#L26-L33

The problem here is that DFX_NETWORK is not defined through Vite, so the process.env.DFX_NETWORK !== "ic" condition is always true and so fetchRootKey is still called on mainnet. You need to define DFX_NETWORK in vite.config.ts. You can see example of this here: examples/svelte/sveltekit-starter/vite.config.ts at master · dfinity/examples · GitHub

That is, even hypothetically agent.fetchRootKey() cannot be called

This will break your application when it’s running locally.

1 Like