Skip to content

Commit

Permalink
fix: change root key fetching logic and specify HttpAgent hostname fo…
Browse files Browse the repository at this point in the history
…r remote environments (#511)

* Change root key fetching logic for remote environments

* Specify HttpAgent host
  • Loading branch information
rvanasa authored Jan 18, 2024
1 parent d0b4ccd commit 8c1161e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/ui/src/candid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ declare var d3: any;

const names: Record<number,string> = {};

function is_local(agent: HttpAgent) {
function isKnownMainnet(agent: HttpAgent) {
// @ts-ignore
const hostname = agent._host.hostname;
return hostname === '127.0.0.1' || hostname.endsWith('localhost');
return hostname.endsWith('.icp0.io') || hostname.endsWith('.ic0.app');
}

export let authClient: AuthClient | undefined;

const agent = new HttpAgent();
if (is_local(agent)) {
const agent = new HttpAgent({ host: window.location.host });
if (!isKnownMainnet(agent)) {
agent.fetchRootKey();
}

Expand Down

0 comments on commit 8c1161e

Please sign in to comment.