Fix PWA offline fallback blocking localhost access when internet is disconnected (#2669) (#2784)

This commit is contained in:
ACX
2026-02-17 16:17:07 -07:00
committed by GitHub
parent 4062f1f83f
commit 43094bb8ef
4 changed files with 179 additions and 8 deletions
+10 -2
View File
@@ -28,7 +28,7 @@ import {scan, withLatestFrom} from 'rxjs/operators';
export class AppComponent implements OnInit, OnDestroy {
loading = true;
offline = !navigator.onLine;
offline = false;
private subscriptions: Subscription[] = [];
private subscriptionsInitialized = false;
@@ -61,9 +61,17 @@ export class AppComponent implements OnInit, OnDestroy {
};
private onOffline = () => {
this.offline = true;
this.checkServerReachable().then(reachable => {
this.offline = !reachable;
});
};
private checkServerReachable(): Promise<boolean> {
return fetch('/api/public/settings', {method: 'HEAD', cache: 'no-store'})
.then(() => true)
.catch(() => false);
}
reload(): void {
window.location.reload();
}