diff --git a/server/server.js b/server/server.js index c2ea82f..9ff07b2 100644 --- a/server/server.js +++ b/server/server.js @@ -392,11 +392,18 @@ app.get('/sw.js', (c) => { return c.text('Service worker not found', 404); } } - // Inject the build tag: replace the placeholder with the real value. + // Inject the build tag: replace the whole fallback expression with the + // real value. Matched by REGEX, not an exact string — an exact match broke + // the moment the fallback literal in sw.js was bumped ('v1.0.3' → 'v1.0.4'), + // after which the replacement silently did nothing, the SW version froze, + // and clients never saw another update no matter how many times we deployed. const src = _swSource.replace( - "typeof __BUILD_TAG__ !== 'undefined' ? __BUILD_TAG__ : 'v1.0.3'", + /typeof __BUILD_TAG__ !== 'undefined' \? __BUILD_TAG__ : '[^']*'/, JSON.stringify(BUILD_TAG) ); + if (src === _swSource) { + console.error('[sw] BUILD_TAG injection failed — placeholder not found in sw.js'); + } return c.text(src, 200, { 'Content-Type': 'application/javascript; charset=utf-8', 'Cache-Control': 'no-store, no-cache, must-revalidate',