Added https redirect

This commit is contained in:
Ildar Kamalov 2019-02-19 15:43:36 +03:00
parent 3c374b5940
commit cca6998efe
5 changed files with 30 additions and 4 deletions
client/src/helpers

View file

@ -140,3 +140,15 @@ export const getWebAddress = (ip, port = '') => {
return address;
};
export const redirectToCurrentProtocol = (values) => {
const { protocol, hostname, hash } = window.location;
const { enabled, port_https } = values;
if (protocol !== 'https:' && enabled && port_https) {
const port = port_https !== 443 ? `:${port_https}` : '';
window.location.replace(`https://${hostname}${port}/${hash}`);
} else if (protocol === 'https:' && (!enabled || !port_https)) {
window.location.replace(`http://${hostname}/${hash}`);
}
};