From da10a34d64973f38d168d9fd2fb622af7c1a5598 Mon Sep 17 00:00:00 2001 From: Aleksandr Gumroian Date: Tue, 11 May 2021 14:49:57 +0200 Subject: [PATCH] Revert "Fix reForis infinity redirect loop when WS error occurs" It turned out that this fix doesn't work as expected in some cases. This reverts commit 7505302875fb0993747b6b122d3977ffdf355452. --- src/webSockets/WebSockets.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/webSockets/WebSockets.js b/src/webSockets/WebSockets.js index 10945f0..55e3af5 100644 --- a/src/webSockets/WebSockets.js +++ b/src/webSockets/WebSockets.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/) + * Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/) * * This is free software, licensed under the GNU General Public License v3. * See /LICENSE for more information. @@ -7,6 +7,8 @@ /* eslint no-console: "off" */ +import { ForisURLs } from "../utils/forisUrls"; + const PROTOCOL = window.location.protocol === "http:" ? "ws" : "wss"; const URL = process.env.LIGHTTPD @@ -19,7 +21,13 @@ export class WebSockets { constructor() { this.ws = new WebSocket(URL); this.ws.onerror = (e) => { - console.error("WS: Error observed:", e); + if (window.location.pathname !== ForisURLs.login) { + console.error( + "WS: Error observed, you aren't logged probably." + ); + window.location.replace(ForisURLs.login); + } + console.error(`WS: Error: ${e}`); }; this.ws.onmessage = (e) => { console.debug(`WS: Received Message: ${e.data}`);