};
},
created: function () {
+ if (/t=\d+/.test(window.location.href)) {
+ window.history.replaceState({}, document.title, window.location.pathname);
+ }
let that = this;
this.checkOffline();
window.addEventListener(
"online",
function () {
- that.checkOffline();
+ that.checkOffline();
},
false
);
// extra check to make sure we're not offline
let that = this;
- return fetch(window.location.href + "?alive", {
+ const urlPath = window.location.pathname.replace(/\/+$/, "");
+ const aliveCheckUrl = `${window.location.origin}${urlPath}/index.html?t=${new Date().valueOf()}`;
+ return fetch(aliveCheckUrl, {
method: "HEAD",
cache: "no-store",
- redirect: "manual"
+ 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);
+ if (
+ (response.type === "opaqueredirect" && !response.ok) ||
+ [401, 403].indexOf(response.status) != -1
+ ) {
+ window.location.href = aliveCheckUrl;
}
that.offline = !response.ok;
})