openvibers/openvibe.exchange Commits

The owner's console is reached again; Not found links properly (#252)

OP OpenVibers committed 6 h ago · 05e68b3d4c · 3 files, +38 −2

Changes

ddiff --git a/server/app.js b/server/app.js
iindex 3c44a09..4ba9577 100644
---- a/server/app.js
++++ b/server/app.js
@@@ -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-vars
app.use((err, req, res, _next) => {
ddiff --git a/server/http/pages.js b/server/http/pages.js
iindex 4f48b4c..9e0f3a1 100644
---- a/server/http/pages.js
++++ b/server/http/pages.js
@@@ -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, {
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;
ddiff --git a/test/console-route-order.test.js b/test/console-route-order.test.js
nnew file mode 100644
iindex 0000000..28a7fd7
---- /dev/null
++++ b/test/console-route-order.test.js
@@@ -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('&lt;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); });