diff --git a/src/components/ConnectivityChecker.vue b/src/components/ConnectivityChecker.vue index 02cbd7f..a717bcf 100644 --- a/src/components/ConnectivityChecker.vue +++ b/src/components/ConnectivityChecker.vue @@ -29,15 +29,40 @@ export default { }, false ); + window.addEventListener( + "online", + function () { + that.checkOffline(); + }, + false + ); + window.addEventListener( + "offline", + function () { + this.offline = true; + }, + false + ); }, methods: { checkOffline: function () { + if (!navigator.onLine) { + this.offline = true; + return; + } + + // extra check to make sure we're not offline let that = this; return fetch(window.location.href + "?alive", { method: "HEAD", cache: "no-store", + redirect: "manual" }) .then(function (response) { + // opaqueredirect means request has been redirected, to auth provider probably + if (response.type === "opaqueredirect" && !response.ok) { + window.location.reload(true); + } that.offline = !response.ok; }) .catch(function () { diff --git a/vue.config.js b/vue.config.js index 410acc8..1645c2f 100644 --- a/vue.config.js +++ b/vue.config.js @@ -26,4 +26,7 @@ module.exports = { msTileImage: "assets/icons/icon-any.png", }, }, + devServer: { + disableHostCheck: true + }, };