fix(dashboard): reload on stale chunk after redeploy
Builds now emit version.json + a __BUILD_VERSION__ define. The client re-checks the remote version on visibilitychange/focus and reloads on mismatch, so a backgrounded tab doesn't hit a 404'd hashed chunk and surface "'text/html' is not a valid JavaScript MIME type" when opening Settings. ErrorBoundary catches stale-chunk errors as a safety net. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -534,9 +534,10 @@ export function registerSettingsMemoryRoutes(ctx: ApiRoutesContext, deps: Settin
|
||||
}
|
||||
: remoteAccess;
|
||||
|
||||
const issued = issueRemoteAuthToken("short-lived", modeSettings);
|
||||
const issuedAtMs = Date.now();
|
||||
const issued = issueRemoteAuthToken("short-lived", modeSettings, issuedAtMs);
|
||||
const effectiveTtlMs = issued.expiresAt
|
||||
? Math.max(0, Date.parse(issued.expiresAt) - Date.now())
|
||||
? Math.max(0, Date.parse(issued.expiresAt) - issuedAtMs)
|
||||
: modeSettings.tokenStrategy.shortLived.ttlMs;
|
||||
res.json({ token: issued.token, expiresAt: issued.expiresAt ?? null, ttlMs: effectiveTtlMs });
|
||||
} catch (err: unknown) {
|
||||
|
||||
@@ -503,6 +503,14 @@ export function createServer(store: TaskStore, options?: ServerOptions): ReturnT
|
||||
: join(__dirname, "..", "client");
|
||||
|
||||
if (!isHeadless) {
|
||||
app.get("/version.json", (_req, res) => {
|
||||
res.setHeader("Cache-Control", "no-store, max-age=0");
|
||||
res.sendFile(join(clientDir, "version.json"), (err) => {
|
||||
if (err) {
|
||||
res.status(404).json({ version: null });
|
||||
}
|
||||
});
|
||||
});
|
||||
app.use(express.static(clientDir));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user