aboutsummaryrefslogtreecommitdiff
path: root/webAO
diff options
context:
space:
mode:
authorDavid Skoland <davidskoland@gmail.com>2023-11-20 00:42:57 +0100
committerDavid Skoland <davidskoland@gmail.com>2023-11-20 21:10:04 +0100
commitced4123cb1c2d507e8795794e1538c6c7b98d2c1 (patch)
tree9abd60751c52603b77dac8f5dd5791ae7df3d817 /webAO
parent4664501188f0f4cace7772c0c1b96d0387df7442 (diff)
Upgrade asset link to https in secure context
Diffstat (limited to 'webAO')
-rw-r--r--webAO/client/aoHost.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/webAO/client/aoHost.ts b/webAO/client/aoHost.ts
index 6cad62a..33e010d 100644
--- a/webAO/client/aoHost.ts
+++ b/webAO/client/aoHost.ts
@@ -3,5 +3,14 @@ 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:');
+ }
+
AO_HOST = val;
}