-
Notifications
You must be signed in to change notification settings - Fork 17
/
setupApp.ts
26 lines (22 loc) · 829 Bytes
/
setupApp.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { Actor } from '@dfinity/agent';
import { getBackend, getNetwork } from './services/backendService';
export const applicationName = 'ICP + Ethereum';
// if (
// window.location.hostname.endsWith('.icp0.io') ||
// window.location.hostname.endsWith('.ic0.app')
// ) {
// // Custom domain name
// window.location.hostname = 'custom.hostname.org';
// }
const dfxPort = 4943;
const url = new URL(window.location.href);
const canisterId = url.searchParams.get('canisterId');
if (canisterId && url.port === String(dfxPort)) {
url.searchParams.delete('canisterId');
// Rewrite to localhost subdomain
window.location.href = `http:https://${canisterId}.localhost:${dfxPort}?${url.searchParams}`;
}
const agent = Actor.agentOf(getBackend());
if (getNetwork() === 'ic') {
(agent as any)._host = 'https://icp-api.io/';
}