Use secure websocket from HTTPS clients (#4436)

Currently, the unsecure `ws://` scheme is hardcoded. With this change,
the scheme will dynamically change to the secure `wss://` when the
frontend is requested from an HTTPS origin.
This commit is contained in:
Sebastian Kippe 2017-02-05 10:04:17 +00:00 committed by Jaco Greeff
parent 4fa1717a99
commit bcd3cd8467

View File

@ -55,6 +55,7 @@ if (process.env.NODE_ENV === 'development') {
const AUTH_HASH = '#/auth?'; const AUTH_HASH = '#/auth?';
const parityUrl = process.env.PARITY_URL || window.location.host; const parityUrl = process.env.PARITY_URL || window.location.host;
const urlScheme = window.location.href.match(/^https/) ? 'wss://' : 'ws://';
let token = null; let token = null;
@ -62,7 +63,7 @@ if (window.location.hash && window.location.hash.indexOf(AUTH_HASH) === 0) {
token = qs.parse(window.location.hash.substr(AUTH_HASH.length)).token; token = qs.parse(window.location.hash.substr(AUTH_HASH.length)).token;
} }
const api = new SecureApi(`ws://${parityUrl}`, token); const api = new SecureApi(`${urlScheme}${parityUrl}`, token);
patchApi(api); patchApi(api);
ContractInstances.create(api); ContractInstances.create(api);