Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client/README.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Spoolman UI

A simple [refine](https://github.com/refinedev/refine) based UI for manipulating the data in the Spoolman database.

## Local Review Cache Reset

Set `VITE_BYPASS_LOOPBACK_PWA_CACHE=true` when you want loopback URLs such as `localhost`, `127.0.0.1`, or `::1` to clear existing service workers and browser caches before the app boots. This is intended for local review and debugging when stale PWA assets are masking the current frontend bundle.
26 changes: 26 additions & 0 deletions client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@ import { createRoot } from "react-dom/client";
import App from "./App";
import "./i18n";

const shouldBypassLoopbackPwaCache = import.meta.env["VITE_BYPASS_LOOPBACK_PWA_CACHE"] === "true";
const normalizedHostname = window.location.hostname.replace(/^\[|\]$/g, "");
const isLoopbackHost =
normalizedHostname === "localhost" ||
normalizedHostname === "::1" ||
/^127(?:\.\d{1,3}){3}$/.test(normalizedHostname);

if (shouldBypassLoopbackPwaCache && isLoopbackHost) {
// Opt-in local review builds can clear loopback-host PWA state before boot so stale assets
// from earlier test runs do not mask the current bundle.
if ("serviceWorker" in navigator) {
void navigator.serviceWorker.getRegistrations().then((registrations) => {
registrations.forEach((registration) => {
void registration.unregister();
});
});
}
if ("caches" in window) {
void caches.keys().then((keys) => {
keys.forEach((key) => {
void caches.delete(key);
});
});
}
}

const container = document.getElementById("root") as HTMLElement;
const root = createRoot(container);

Expand Down