mirror of
https://github.com/bastienwirtz/homer.git
synced 2025-11-15 17:45:52 +01:00
feat(pwa): enhance connectivity checks
Also add support to auth proxy such as Authelia
This commit is contained in:
@@ -29,15 +29,40 @@ export default {
|
|||||||
},
|
},
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
window.addEventListener(
|
||||||
|
"online",
|
||||||
|
function () {
|
||||||
|
that.checkOffline();
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
window.addEventListener(
|
||||||
|
"offline",
|
||||||
|
function () {
|
||||||
|
this.offline = true;
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
checkOffline: function () {
|
checkOffline: function () {
|
||||||
|
if (!navigator.onLine) {
|
||||||
|
this.offline = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// extra check to make sure we're not offline
|
||||||
let that = this;
|
let that = this;
|
||||||
return fetch(window.location.href + "?alive", {
|
return fetch(window.location.href + "?alive", {
|
||||||
method: "HEAD",
|
method: "HEAD",
|
||||||
cache: "no-store",
|
cache: "no-store",
|
||||||
|
redirect: "manual"
|
||||||
})
|
})
|
||||||
.then(function (response) {
|
.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;
|
that.offline = !response.ok;
|
||||||
})
|
})
|
||||||
.catch(function () {
|
.catch(function () {
|
||||||
|
|||||||
@@ -26,4 +26,7 @@ module.exports = {
|
|||||||
msTileImage: "assets/icons/icon-any.png",
|
msTileImage: "assets/icons/icon-any.png",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
devServer: {
|
||||||
|
disableHostCheck: true
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user