aboutsummaryrefslogtreecommitdiff
path: root/webAO/client/aoHost.ts
blob: 4501104f372e0d157ee650d755c89a6a349c652e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import queryParser from "../utils/queryParser";

const { asset } = queryParser();
export let AO_HOST = asset;
export const setAOhost = (val: string) => {
  const currentProtocol = window.location.protocol;
  const assetProtocol = val.split(":")[0] + ":";

  if (currentProtocol === "https:" && assetProtocol === "http:") {
    // In this specific case, we need to request assets over HTTPS
    console.log("Upgrading asset link to https");
    val = val.replace("http:", "https:");
  }
  if (AO_HOST.length < 5) {
    AO_HOST = val;
  }  
};