diff options
author | Pierre <397503+bemble@users.noreply.github.com> | 2022-05-09 23:47:05 +0200 |
---|---|---|
committer | Pierre <397503+bemble@users.noreply.github.com> | 2022-05-09 23:47:05 +0200 |
commit | bf2fcc6641643018bd5224ec2f8308173d54cfa4 (patch) | |
tree | 8046f8e937eed5b59d479f85080656053e46475d | |
parent | 2ac75c05349ee4315bfdad238504e6693adc322d (diff) | |
download | homer-bf2fcc6641643018bd5224ec2f8308173d54cfa4.tar.gz homer-bf2fcc6641643018bd5224ec2f8308173d54cfa4.tar.zst homer-bf2fcc6641643018bd5224ec2f8308173d54cfa4.zip |
feat(pwa): enhance connectivity checks
Also add support to auth proxy such as Authelia
-rw-r--r-- | src/components/ConnectivityChecker.vue | 25 | ||||
-rw-r--r-- | vue.config.js | 3 |
2 files changed, 28 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 () { |
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 = { | |||
26 | msTileImage: "assets/icons/icon-any.png", | 26 | msTileImage: "assets/icons/icon-any.png", |
27 | }, | 27 | }, |
28 | }, | 28 | }, |
29 | devServer: { | ||
30 | disableHostCheck: true | ||
31 | }, | ||
29 | }; | 32 | }; |