# Generated declarations in Node.js environment break

**URL:** <https://forum.dfinity.org/t/generated-declarations-in-node-js-environment-break/12686>\
**Category:** Developers\
**Created:** [May 3, 2022, 2:54pm UTC](https://forum.dfinity.org/t/generated-declarations-in-node-js-environment-break/12686 "2022-05-03T14:54:44Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [May 4, 2022, 7:22pm UTC](https://forum.dfinity.org/t/generated-declarations-in-node-js-environment-break/12686/21 "2022-05-04T19:22:47Z")

</div>

> [@anon74414410](#):
>
> Furthermore, there’s no way to know what the root key of a local environment is without making an async call to the network, since it will change each time it is spun up. The only network we can be sure of is mainnet. I feel the pain, but I don’t know of a way around it.

Can you explain the issue with having a hard-coded key for the local replica environment? Is there some issue with the local dfx replicas all having the same key for development?

Seems like a simple fix to just hard-code that if using dfx. I understand that there might be other deployments of the IC, such as test networks or who knows other production or private networks later on. But I think there should be an option to hard-code it for this case.

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [May 4, 2022, 8:07pm UTC](https://forum.dfinity.org/t/generated-declarations-in-node-js-environment-break/12686/22 "2022-05-04T20:07:16Z")

</div>

How does JavaScript know that we’re using dfx?

---

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [May 4, 2022, 8:22pm UTC](https://forum.dfinity.org/t/generated-declarations-in-node-js-environment-break/12686/23 "2022-05-04T20:22:34Z")

</div>

Yeah good point, but perhaps there’s a simple setting we could pass into the agent on creation.

---

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [May 4, 2022, 8:24pm UTC](https://forum.dfinity.org/t/generated-declarations-in-node-js-environment-break/12686/24 "2022-05-04T20:24:27Z")

</div>

Perhaps the agent can just use the hard-coded keys basing it off of the URL (isn’t that how it knows to use the hard-coded production key?), if it’s a URL that looks local (localhost or 127.0.01 etc) then it can use the hard-coded development key. And only outside of those two situations (which currently would be very rare), a custom key can be fetched.

---

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [May 4, 2022, 8:25pm UTC](https://forum.dfinity.org/t/generated-declarations-in-node-js-environment-break/12686/25 "2022-05-04T20:25:29Z")

</div>

It knows we’re using the production IC somehow, I assume based on the URL. Same type of process can be used to determine if we’re local right?

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [May 4, 2022, 10:06pm UTC](https://forum.dfinity.org/t/generated-declarations-in-node-js-environment-break/12686/26 "2022-05-04T22:06:52Z")

</div>

URL is only a thing in a browser context though. Also, when custom domains come into play, it becomes even more complicated.

the `host` passed to the `httpAgent` would be the best existing feature to hook into, but at the moment that’s private, so the only time we’d know whether to use it for `fetchRootKey` would be to check it in the `createActor` args, so that might be a safe enough enhancement

---

<div class="post-metadata">

**Author:** ![Safik](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/safik/32/953_2.png) [@Safik](https://forum.dfinity.org/u/Safik)\
**Post date:** [May 20, 2022, 11:59am UTC](https://forum.dfinity.org/t/generated-declarations-in-node-js-environment-break/12686/27 "2022-05-20T11:59:21Z")

</div>

Hi. I have a question (or suggestion) in the local environment if several Actors (Canisters) are randomly generating identifiers. Is it possible to somehow hard-link them in the dfx.json file?

For example

```auto
const canister_id_service_dbs = "ryjl3-tyaaa-aaaaa-aaaba-cai";
const canister_id_service_token = "r7inp-6aaaa-aaaaa-aaabq-cai";

```

Each time you have to reassign to correctly generated ones (this is in the local environment)

I would like something similar to canister\_ids.json

---

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [September 1, 2022, 8:18pm UTC](https://forum.dfinity.org/t/generated-declarations-in-node-js-environment-break/12686/28 "2022-09-01T20:18:55Z")

</div>

Is this available yet?

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [September 1, 2022, 10:00pm UTC](https://forum.dfinity.org/t/generated-declarations-in-node-js-environment-break/12686/29 "2022-09-01T22:00:49Z")

</div>

Weirdly, we seem to have released 0.11.2 recently, but it doesn’t seem to have the feature yet. The feature will be in 0.12.0, and you can try it out today by installing `0.12.0-beta.1`

[Previous page](https://forum.dfinity.org/t/generated-declarations-in-node-js-environment-break/12686.md?page=1)
