openvibers/openvibe.exchange Commits
The owner's console is reached again; Not found links properly (#252)
Changes
@@@ -389,8 +389,12 @@ async function createApp(opts = {}) {app.use(require('./http/dashboard').createDashboardRoutes(ctx));app.use(require('./http/search').createSearchRoutes(ctx));app.use(require('./http/deep-dive').createDeepDiveRoutes(ctx));++ // The owner's console before the pages: the pages end in their Not found, so a console mounted after them was never++ // reached (every /console page answered "Nothing lives at", 11-13; the admin guide links to /console/providers).++ // Only /console reaches it: its owner check is for every request the router sees.++ const consoleRoutes = createConsoleRoutes(ctx);++ app.use((req, res, next) => (req.path === '/console' || req.path.startsWith('/console/') ? consoleRoutes(req, res, next) : next()));app.use(createPageRoutes(ctx));-- app.use(createConsoleRoutes(ctx));// eslint-disable-next-line no-unused-varsapp.use((err, req, res, _next) => {@@@ -988,7 +988,7 @@ ${m.meta && m.meta.cached_input_percent != null ? `<dt>Cached input</dt><dd>${Nur.use((req, res) => page(req, res, {title: 'Not found', index: false,-- body: raw(`<div class="ex-wrap ex-narrow">${kit.empty({ icon: 'search', title: 'Not found', text: `Nothing lives at ${esc(req.path)}. <a href="/">The home</a> has every model.` })}</div>`),++ body: raw(`<div class="ex-wrap ex-narrow">${kit.empty({ icon: 'search', title: 'Not found', text: `Nothing lives at ${req.path}.`, action: { href: '/', label: 'Every model' } })}</div>`),}, 404));return r;nnew file mode 100644@@@ -0,0 +1,32 @@++'use strict';++/**++ * The owner's console is reached (2026-11-13): it was mounted after the pages, whose Not found answered every path++ * first, so /console/providers (where the admin guide sends the owner) said "Nothing lives at". Only /console reaches++ * the console's router (its owner check is for every request it sees), so the pages still answer everyone else, and++ * the pages' own Not found carries its link as a link, not as escaped markup.++ */++const assert = require('assert');++const { boot, check, done } = require('./helpers/boot');++const { createFakeAi } = require('./helpers/ai');++++(async () => {++ const t = await boot({ ai: createFakeAi() });++ try {++ await check('/console is the console\'s, not the pages\' Not found', async () => {++ const r = await t.get('/console/providers');++ assert.strictEqual(r.status, 404, 'signed out: the console\'s own 404');++ assert.ok(!r.text.includes('Nothing lives at'), 'not the pages\' Not found');++ });++ await check('the pages answer everyone else as before', async () => {++ assert.strictEqual((await t.get('/')).status, 200);++ assert.strictEqual((await t.get('/models')).status, 200);++ });++ await check('the pages\' Not found has a real link', async () => {++ const r = await t.get('/no-such-page');++ assert.strictEqual(r.status, 404);++ assert.ok(r.text.includes('Nothing lives at /no-such-page.'), 'says where');++ assert.ok(!r.text.includes('<a href'), 'no escaped markup');++ assert.ok(/<a[^>]+href="\/"[^>]*>[\s\S]*?Every model/.test(r.text), 'a link to every model');++ });++ } finally { await done(t); }++})().catch((e) => { console.error(e); process.exit(1); });
@@ -389,8 +389,12 @@ async function createApp(opts = {}) {
@@ -389,8 +389,12 @@ async function createApp(opts = {}) {
app.use(require('./http/dashboard').createDashboardRoutes(ctx));
app.use(require('./http/dashboard').createDashboardRoutes(ctx));
app.use(require('./http/search').createSearchRoutes(ctx));
app.use(require('./http/search').createSearchRoutes(ctx));
app.use(require('./http/deep-dive').createDeepDiveRoutes(ctx));
app.use(require('./http/deep-dive').createDeepDiveRoutes(ctx));
+ // The owner's console before the pages: the pages end in their Not found, so a console mounted after them was never
+ // reached (every /console page answered "Nothing lives at", 11-13; the admin guide links to /console/providers).
+ // Only /console reaches it: its owner check is for every request the router sees.
+ const consoleRoutes = createConsoleRoutes(ctx);
+ app.use((req, res, next) => (req.path === '/console' || req.path.startsWith('/console/') ? consoleRoutes(req, res, next) : next()));
app.use(createPageRoutes(ctx));
app.use(createPageRoutes(ctx));
- app.use(createConsoleRoutes(ctx));
// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line no-unused-vars
app.use((err, req, res, _next) => {
app.use((err, req, res, _next) => {
@@ -988,7 +988,7 @@ ${m.meta && m.meta.cached_input_percent != null ? `<dt>Cached input</dt><dd>${Nu
@@ -988,7 +988,7 @@ ${m.meta && m.meta.cached_input_percent != null ? `<dt>Cached input</dt><dd>${Nu
r.use((req, res) => page(req, res, {
r.use((req, res) => page(req, res, {
title: 'Not found', index: false,
title: 'Not found', index: false,
- body: raw(`<div class="ex-wrap ex-narrow">${kit.empty({ icon: 'search', title: 'Not found', text: `Nothing lives at ${esc(req.path)}. <a href="/">The home</a> has every model.` })}</div>`),
+ body: raw(`<div class="ex-wrap ex-narrow">${kit.empty({ icon: 'search', title: 'Not found', text: `Nothing lives at ${req.path}.`, action: { href: '/', label: 'Every model' } })}</div>`),
}, 404));
}, 404));
return r;
return r;
new file mode 100644
new file mode 100644
@@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
+'use strict';
+/**
+ * The owner's console is reached (2026-11-13): it was mounted after the pages, whose Not found answered every path
+ * first, so /console/providers (where the admin guide sends the owner) said "Nothing lives at". Only /console reaches
+ * the console's router (its owner check is for every request it sees), so the pages still answer everyone else, and
+ * the pages' own Not found carries its link as a link, not as escaped markup.
+ */
+const assert = require('assert');
+const { boot, check, done } = require('./helpers/boot');
+const { createFakeAi } = require('./helpers/ai');
+
+(async () => {
+ const t = await boot({ ai: createFakeAi() });
+ try {
+ await check('/console is the console\'s, not the pages\' Not found', async () => {
+ const r = await t.get('/console/providers');
+ assert.strictEqual(r.status, 404, 'signed out: the console\'s own 404');
+ assert.ok(!r.text.includes('Nothing lives at'), 'not the pages\' Not found');
+ });
+ await check('the pages answer everyone else as before', async () => {
+ assert.strictEqual((await t.get('/')).status, 200);
+ assert.strictEqual((await t.get('/models')).status, 200);
+ });
+ await check('the pages\' Not found has a real link', async () => {
+ const r = await t.get('/no-such-page');
+ assert.strictEqual(r.status, 404);
+ assert.ok(r.text.includes('Nothing lives at /no-such-page.'), 'says where');
+ assert.ok(!r.text.includes('<a href'), 'no escaped markup');
+ assert.ok(/<a[^>]+href="\/"[^>]*>[\s\S]*?Every model/.test(r.text), 'a link to every model');
+ });
+ } finally { await done(t); }
+})().catch((e) => { console.error(e); process.exit(1); });