aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components
diff options
context:
space:
mode:
authorPierre <397503+bemble@users.noreply.github.com>2022-05-09 23:47:05 +0200
committerPierre <397503+bemble@users.noreply.github.com>2022-05-09 23:47:05 +0200
commitbf2fcc6641643018bd5224ec2f8308173d54cfa4 (patch)
tree8046f8e937eed5b59d479f85080656053e46475d /src/components
parent2ac75c05349ee4315bfdad238504e6693adc322d (diff)
downloadhomer-bf2fcc6641643018bd5224ec2f8308173d54cfa4.tar.gz
homer-bf2fcc6641643018bd5224ec2f8308173d54cfa4.tar.zst
homer-bf2fcc6641643018bd5224ec2f8308173d54cfa4.zip
feat(pwa): enhance connectivity checks
Also add support to auth proxy such as Authelia
Diffstat (limited to 'src/components')
-rw-r--r--src/components/ConnectivityChecker.vue25
1 files changed, 25 insertions, 0 deletions
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 {
29 }, 29 },
30 false 30 false
31 ); 31 );
32 window.addEventListener(
33 "online",
34 function () {
35 that.checkOffline();
36 },
37 false
38 );
39 window.addEventListener(
40 "offline",
41 function () {
42 this.offline = true;
43 },
44 false
45 );
32 }, 46 },
33 methods: { 47 methods: {
34 checkOffline: function () { 48 checkOffline: function () {
49 if (!navigator.onLine) {
50 this.offline = true;
51 return;
52 }
53
54 // extra check to make sure we're not offline
35 let that = this; 55 let that = this;
36 return fetch(window.location.href + "?alive", { 56 return fetch(window.location.href + "?alive", {
37 method: "HEAD", 57 method: "HEAD",
38 cache: "no-store", 58 cache: "no-store",
59 redirect: "manual"
39 }) 60 })
40 .then(function (response) { 61 .then(function (response) {
62 // opaqueredirect means request has been redirected, to auth provider probably
63 if (response.type === "opaqueredirect" && !response.ok) {
64 window.location.reload(true);
65 }
41 that.offline = !response.ok; 66 that.offline = !response.ok;
42 }) 67 })
43 .catch(function () { 68 .catch(function () {