openvibers/openvibe.network Commits

Link answers a machine's old sub-paths on its hub (#746)

OP OpenVibers committed 3 days ago · 4071220252 · 3 files, +13 −2

The machines hub is the one page openvibe.link/machines has, so a path below it
(a machine's screen or desks, as Bot's old pages and Actor's Watch links name
them) now answers a 301 to the hub instead of falling through the catch-all to
openvibe.network/machines/..., which has no page.

The openvibe.link vhost passes /machines/... to Network for that; without it
nginx sends those paths to the catch-all before the app sees them.

Changes

ddiff --git a/deploy/nginx/parked-domains.conf b/deploy/nginx/parked-domains.conf
iindex f9f29a11..14569fe2 100644
---- a/deploy/nginx/parked-domains.conf
++++ b/deploy/nginx/parked-domains.conf
@@@ -202,7 +202,7 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
add_header Cache-Control "no-store" always;
}
-- location ~ ^/(|install|machines|pair|index\.md|send\.js|egress-settings\.js|locker\.mjs|llms\.txt|llms-full\.txt|robots\.txt|sitemap\.xml|\.well-known/agent\.json)$ {
++ location ~ ^/(|install|machines(/.*)?|pair|index\.md|send\.js|egress-settings\.js|locker\.mjs|llms\.txt|llms-full\.txt|robots\.txt|sitemap\.xml|\.well-known/agent\.json)$ {
limit_except GET HEAD { deny all; }
proxy_pass http://127.0.0.1:4000;
proxy_http_version 1.1;
ddiff --git a/server/link/routes.js b/server/link/routes.js
iindex 48622a42..f2419b46 100644
---- a/server/link/routes.js
++++ b/server/link/routes.js
@@@ -86,6 +86,11 @@ function createLinkRoutes({ releaseId, releaseApi = release } = {}) {
if (path === '/machines') {
return res.set('Cache-Control', 'no-store').sendFile(pathLib.join(__dirname, '..', '..', 'public', 'my.html'));
}
++ // Older links name a machine's screen, desks or pairing below /machines (Actor's Watch links, Bot's old
++ // pages). The hub is the one page this host has, so they land on it instead of the catch-all's Network 404.
++ if (path.startsWith('/machines/')) {
++ return res.set('Cache-Control', 'no-store').redirect(301, `${SITE}/machines`);
++ }
if (path === '/pair' || path === '/panel') {
return res.set('Cache-Control', 'no-store').redirect(302, `${SITE}/machines`);
}
ddiff --git a/test/link-home.test.js b/test/link-home.test.js
iindex 24c229f3..5e105e8c 100644
---- a/test/link-home.test.js
++++ b/test/link-home.test.js
@@@ -61,7 +61,7 @@ const SHAPED = {
// The vhost must send /machines and /pair to the app (which signposts them), not the catch-all to Network.
const vhost = fs.readFileSync(path.join(__dirname, '..', 'deploy', 'nginx', 'parked-domains.conf'), 'utf8');
-- assert.ok(/location ~ \^\/\(\|install\|machines\|pair\|index\\\.md\|send\\\.js\|egress-settings\\\.js\|locker\\\.mjs\|/.test(vhost), 'the vhost passes the page\'s scripts (send.js, egress-settings.js) and the Locker bundle to Network');
++ assert.ok(/location ~ \^\/\(\|install\|machines(?:\(\/\.\*\)\?)?\|pair\|index\\\.md\|send\\\.js\|egress-settings\\\.js\|locker\\\.mjs\|/.test(vhost), 'the vhost passes the page\'s scripts (send.js, egress-settings.js), the machine hub and its old sub-paths, and the Locker bundle to Network');
const sendApi = vhost.slice(vhost.indexOf('location ~ ^/api/v1/me/nodes/(send-keys|send)$ {'));
assert.ok(sendApi.length < vhost.length && /client_max_body_size 40m;/.test(sendApi.slice(0, sendApi.indexOf('\n }'))), 'the Link Send API has its own location with a body limit that fits a file');
// …and /auth/* to Link's own sign-in (Network#664), or openvibe.link never signs anyone in (11-08 audit).
@@@ -216,6 +216,12 @@ const SHAPED = {
assert.strictEqual(hub.status, 302, `${p} opens the Link machine hub`);
assert.strictEqual(hub.headers.location, 'https://openvibe.link/machines');
}
++ // Bot's old sub-paths (and Actor's Watch links) land on the hub rather than the catch-all's Network 404.
++ for (const p of ['/machines/dev_01ABC/screen?desk=desk-task-a', '/machines/dev_01ABC/desks']) {
++ const sub = await get(p, 'openvibe.link');
++ assert.strictEqual(sub.status, 301, `${p} goes to the hub`);
++ assert.strictEqual(sub.headers.location, 'https://openvibe.link/machines');
++ }
const www = await get('/', 'www.openvibe.link');
assert.strictEqual(www.status, 301, 'www 301s');