From ae6d5cb6bfeda0b22956972502880fb08f8179b5 Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Fri, 5 Mar 2021 06:30:41 +0800 Subject: [PATCH] Improvements to automatic redirect on loading SEA module (#1055) * Warn on automatic redirect to HTTPS * Don't redirect to HTTPS on loopback IP addresses * Check if current location is a local loopback IP address (127.0.0.0/8) and do not redirect --- sea.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sea.js b/sea.js index c25ab5d7..2bcb0a26 100644 --- a/sea.js +++ b/sea.js @@ -35,7 +35,9 @@ try{ if(SEA.window){ if(location.protocol.indexOf('s') < 0 && location.host.indexOf('localhost') < 0 + && ! /^127\.\d+\.\d+\.\d+$/.test(location.hostname) && location.protocol.indexOf('file:') < 0){ + console.warn('WebCrypto used by GUN SEA implementation does not work without HTTPS. Will automatically redirect.') location.protocol = 'https:'; // WebCrypto does NOT work without HTTPS! } } }catch(e){}