openvibers/openvibe.live Commits
Serve "/" through the renderer for every client, not only Accept: text/html
Changes
@@@ -535,7 +535,9 @@ app.use((req, res, next) => {if ((req.method !== 'GET' && req.method !== 'HEAD') || !req.path.endsWith('.html')) return next();if (!sendDocument(res, req.path.slice(1))) return next();});--app.use(express.static(assets.PUBLIC_DIR, { setHeaders: (res, filePath) => { if (filePath.endsWith('.html')) noCacheHeaders(res); } }));++// index: false — "/" must reach sendDocument (the SPA fallback), never the raw index.html with its++// unfilled route markers and unversioned asset URLs (a request without Accept: text/html skips SEO).++app.use(express.static(assets.PUBLIC_DIR, { index: false, setHeaders: (res, filePath) => { if (filePath.endsWith('.html')) noCacheHeaders(res); } }));// Ensure data directories exist. VOD/clip/paste/thumbnail files live in// OpenVibe.Media now; what remains is Live-local state (live thumbs, emotes,@@@ -122,6 +122,13 @@ async function check(name, fn) {}});++ await check('the public static mount never serves index.html for "/" (it would skip rendering)', () => {++ const src = fs.readFileSync(path.join(__dirname, '../server/index.js'), 'utf8');++ const mount = src.match(/app\.use\(express\.static\(assets\.PUBLIC_DIR,[^\n]*/);++ assert.ok(mount, 'root static mount not found');++ assert.match(mount[0], /index:\s*false/);++ });++server.close();fs.rmSync(base, { recursive: true, force: true });if (failures) { console.log(`\n${failures} failure(s)`); process.exit(1); }
@@ -535,7 +535,9 @@ app.use((req, res, next) => {
@@ -535,7 +535,9 @@ app.use((req, res, next) => {
if ((req.method !== 'GET' && req.method !== 'HEAD') || !req.path.endsWith('.html')) return next();
if ((req.method !== 'GET' && req.method !== 'HEAD') || !req.path.endsWith('.html')) return next();
if (!sendDocument(res, req.path.slice(1))) return next();
if (!sendDocument(res, req.path.slice(1))) return next();
});
});
-app.use(express.static(assets.PUBLIC_DIR, { setHeaders: (res, filePath) => { if (filePath.endsWith('.html')) noCacheHeaders(res); } }));
+// index: false — "/" must reach sendDocument (the SPA fallback), never the raw index.html with its
+// unfilled route markers and unversioned asset URLs (a request without Accept: text/html skips SEO).
+app.use(express.static(assets.PUBLIC_DIR, { index: false, setHeaders: (res, filePath) => { if (filePath.endsWith('.html')) noCacheHeaders(res); } }));
// Ensure data directories exist. VOD/clip/paste/thumbnail files live in
// Ensure data directories exist. VOD/clip/paste/thumbnail files live in
// OpenVibe.Media now; what remains is Live-local state (live thumbs, emotes,
// OpenVibe.Media now; what remains is Live-local state (live thumbs, emotes,
@@ -122,6 +122,13 @@ async function check(name, fn) {
@@ -122,6 +122,13 @@ async function check(name, fn) {
}
}
});
});
+ await check('the public static mount never serves index.html for "/" (it would skip rendering)', () => {
+ const src = fs.readFileSync(path.join(__dirname, '../server/index.js'), 'utf8');
+ const mount = src.match(/app\.use\(express\.static\(assets\.PUBLIC_DIR,[^\n]*/);
+ assert.ok(mount, 'root static mount not found');
+ assert.match(mount[0], /index:\s*false/);
+ });
+
server.close();
server.close();
fs.rmSync(base, { recursive: true, force: true });
fs.rmSync(base, { recursive: true, force: true });
if (failures) { console.log(`\n${failures} failure(s)`); process.exit(1); }
if (failures) { console.log(`\n${failures} failure(s)`); process.exit(1); }