Skip to content

Don't incite developers to bake the canister ID in the frontend #2014

Closed
@nmattia

Description

@nmattia

The default webpack.config.js injects the canister ID in the build as an environment variable. This is not ideal for the following reasons:

  • It incites users to actually use the canister ID in the frontend build, effectively baking the value in and preventing the module from being deployed in different environments, as it is unlikely the newly created canisters will receive the same canister ID.
  • It prevents anyone from building the frontend code with e.g. npm run build before the canisters have been created, since the default config will (try to) load the canister IDs from .dfx/<network>/canister_ids.json (a file and filepath which are, AFAICT, undocumented).

In the internet identity dapp we work around this by

I think those are good practices, maybe they could be added to the default generated canisters and examples?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions