openvibers/openvibe.network Commits
Route retired Node host before Network home renderer (#846)
Changes
@@@ -756,6 +756,11 @@ const tryNext = require('./home/try-next').createTryNext({ db, popularity: homeP// The Node's own front door on its own subdomain (openvibe.link): the Host header decides. It mounts// before the agent layer, so the Node's page is not answered by Network's home renderer.app.use(require('./link/routes').createLinkRoutes({ release: release.release, db, config, publicKey }));++// The retired Node host must leave before the agent layer answers '/' with Network's public home.++app.get('/', (req, res, next) => {++ if (getRequestHost(req) === 'node.openvibe.network') return res.redirect(302, 'https://openvibe.link/machines');++ return next();++});// The agent layer (openvibe-shared/agent-layer): /.well-known/agent.json, and the public pages as Markdown twins. It// answers their HTML as well, with the discovery tags in the head, so it mounts before the routes for those pages.require('openvibe-shared/agent-layer').mount(app, {@@@ -1156,9 +1161,6 @@ app.get('/apps', connectPage);app.get('/apps.html', (req, res) => redirectWithoutHtml(req, res, '/apps'));app.get('/', (req, res, next) => {if (getRequestHost(req) === 'connect.openvibe.network') return connectPage(req, res);-- // The Node host has no browser session of its own. Send its front door to the-- // signed-in Machines hub instead of serving the Network home under another origin.-- if (getRequestHost(req) === 'node.openvibe.network') return res.redirect(302, 'https://openvibe.link/machines');return next();});app.get('/pay/:id', (_req, res) => sendPayPage(res));@@@ -4,6 +4,7 @@// its 200 and that anything else is a 404: a small noindex page, or JSON under /api, /internal, /oauth.// node test/unknown-paths.test.jsconst assert = require('assert');++const http = require('node:http');const { bootServer } = require('./helpers/boot-server');const { ACCOUNT_HUB_PATHS } = require('../server/not-found');@@@ -28,6 +29,16 @@ const { ACCOUNT_HUB_PATHS } = require('../server/not-found');const r = await get(p);assert.strictEqual(r.status, 200, `${p} is a real page: 200 (got ${r.status})`);}++ const nodeHost = ['node', 'openvibe', 'network'].join('.');++ const nodeArrival = await new Promise((resolve, reject) => {++ const req = http.get(srv.base + '/', { headers: { Host: nodeHost } }, res => {++ res.resume();++ res.on('end', () => resolve({ status: res.statusCode, location: res.headers.location }));++ });++ req.on('error', reject);++ });++ assert.strictEqual(nodeArrival.status, 302, 'the retired Node host leaves before the agent layer renders Network home');++ assert.strictEqual(nodeArrival.location, 'https://openvibe.link/machines');assert.strictEqual((await get('/sso/check')).status, 400, '/sso/check is a route (400 without its parameters), not a 404');// The crawl files are generated routes (server/seo/routes.js), not the static files in public/.const robots = await get('/robots.txt');
@@ -756,6 +756,11 @@ const tryNext = require('./home/try-next').createTryNext({ db, popularity: homeP
@@ -756,6 +756,11 @@ const tryNext = require('./home/try-next').createTryNext({ db, popularity: homeP
// The Node's own front door on its own subdomain (openvibe.link): the Host header decides. It mounts
// The Node's own front door on its own subdomain (openvibe.link): the Host header decides. It mounts
// before the agent layer, so the Node's page is not answered by Network's home renderer.
// before the agent layer, so the Node's page is not answered by Network's home renderer.
app.use(require('./link/routes').createLinkRoutes({ release: release.release, db, config, publicKey }));
app.use(require('./link/routes').createLinkRoutes({ release: release.release, db, config, publicKey }));
+// The retired Node host must leave before the agent layer answers '/' with Network's public home.
+app.get('/', (req, res, next) => {
+ if (getRequestHost(req) === 'node.openvibe.network') return res.redirect(302, 'https://openvibe.link/machines');
+ return next();
+});
// The agent layer (openvibe-shared/agent-layer): /.well-known/agent.json, and the public pages as Markdown twins. It
// The agent layer (openvibe-shared/agent-layer): /.well-known/agent.json, and the public pages as Markdown twins. It
// answers their HTML as well, with the discovery tags in the head, so it mounts before the routes for those pages.
// answers their HTML as well, with the discovery tags in the head, so it mounts before the routes for those pages.
require('openvibe-shared/agent-layer').mount(app, {
require('openvibe-shared/agent-layer').mount(app, {
@@ -1156,9 +1161,6 @@ app.get('/apps', connectPage);
@@ -1156,9 +1161,6 @@ app.get('/apps', connectPage);
app.get('/apps.html', (req, res) => redirectWithoutHtml(req, res, '/apps'));
app.get('/apps.html', (req, res) => redirectWithoutHtml(req, res, '/apps'));
app.get('/', (req, res, next) => {
app.get('/', (req, res, next) => {
if (getRequestHost(req) === 'connect.openvibe.network') return connectPage(req, res);
if (getRequestHost(req) === 'connect.openvibe.network') return connectPage(req, res);
- // The Node host has no browser session of its own. Send its front door to the
- // signed-in Machines hub instead of serving the Network home under another origin.
- if (getRequestHost(req) === 'node.openvibe.network') return res.redirect(302, 'https://openvibe.link/machines');
return next();
return next();
});
});
app.get('/pay/:id', (_req, res) => sendPayPage(res));
app.get('/pay/:id', (_req, res) => sendPayPage(res));
@@ -4,6 +4,7 @@
@@ -4,6 +4,7 @@
// its 200 and that anything else is a 404: a small noindex page, or JSON under /api, /internal, /oauth.
// its 200 and that anything else is a 404: a small noindex page, or JSON under /api, /internal, /oauth.
// node test/unknown-paths.test.js
// node test/unknown-paths.test.js
const assert = require('assert');
const assert = require('assert');
+const http = require('node:http');
const { bootServer } = require('./helpers/boot-server');
const { bootServer } = require('./helpers/boot-server');
const { ACCOUNT_HUB_PATHS } = require('../server/not-found');
const { ACCOUNT_HUB_PATHS } = require('../server/not-found');
@@ -28,6 +29,16 @@ const { ACCOUNT_HUB_PATHS } = require('../server/not-found');
@@ -28,6 +29,16 @@ const { ACCOUNT_HUB_PATHS } = require('../server/not-found');
const r = await get(p);
const r = await get(p);
assert.strictEqual(r.status, 200, `${p} is a real page: 200 (got ${r.status})`);
assert.strictEqual(r.status, 200, `${p} is a real page: 200 (got ${r.status})`);
}
}
+ const nodeHost = ['node', 'openvibe', 'network'].join('.');
+ const nodeArrival = await new Promise((resolve, reject) => {
+ const req = http.get(srv.base + '/', { headers: { Host: nodeHost } }, res => {
+ res.resume();
+ res.on('end', () => resolve({ status: res.statusCode, location: res.headers.location }));
+ });
+ req.on('error', reject);
+ });
+ assert.strictEqual(nodeArrival.status, 302, 'the retired Node host leaves before the agent layer renders Network home');
+ assert.strictEqual(nodeArrival.location, 'https://openvibe.link/machines');
assert.strictEqual((await get('/sso/check')).status, 400, '/sso/check is a route (400 without its parameters), not a 404');
assert.strictEqual((await get('/sso/check')).status, 400, '/sso/check is a route (400 without its parameters), not a 404');
// The crawl files are generated routes (server/seo/routes.js), not the static files in public/.
// The crawl files are generated routes (server/seo/routes.js), not the static files in public/.
const robots = await get('/robots.txt');
const robots = await get('/robots.txt');