From ced4123cb1c2d507e8795794e1538c6c7b98d2c1 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Mon, 20 Nov 2023 00:42:57 +0100 Subject: Upgrade asset link to https in secure context --- webAO/client/aoHost.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'webAO/client/aoHost.ts') 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; } -- cgit