Skip to content

Commit

Permalink
Explorer: Disable cluster url replacement on localhost (solana-labs#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry authored Oct 14, 2022
1 parent dd7fee8 commit f627b7d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions explorer/src/providers/cluster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,21 @@ export const TESTNET_URL = clusterApiUrl("testnet");
export const DEVNET_URL = clusterApiUrl("devnet");

export function clusterUrl(cluster: Cluster, customUrl: string): string {
const modifyUrl = (url: string): string => {
if (window.location.hostname === "localhost") {
return url;
} else {
return url.replace("api", "explorer-api");
}
};

switch (cluster) {
case Cluster.Devnet:
return DEVNET_URL.replace("api", "explorer-api");
return modifyUrl(DEVNET_URL);
case Cluster.MainnetBeta:
return MAINNET_BETA_URL.replace("api", "explorer-api");
return modifyUrl(MAINNET_BETA_URL);
case Cluster.Testnet:
return TESTNET_URL.replace("api", "explorer-api");
return modifyUrl(TESTNET_URL);
case Cluster.Custom:
return customUrl;
}
Expand Down

0 comments on commit f627b7d

Please sign in to comment.