feat(wiki): serve the legal pages at /terms-of-service and /privacy-policy
Discord, and most platforms, ask for a terms URL and a privacy URL in a form field; pasting a `/wiki/...` address there reads like an afterthought. Both pages now answer at the root, while everything else stays under `/wiki/`. The API states each page's address instead of leaving the front to rebuild it, so there is one place that decides. Existing pages are renamed rather than recreated, keeping whatever has already been written in them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
e1b9a5cc77
commit
3d0e21d7cb
7 files changed
+83
-26
No files matched your search
+8
-3
@@ -11,7 +11,7 @@ import { authorize } from './auth/guard.js';
|
||||
import { broadcast, closeEventStreams, topicForPath } from './events.js';
|
||||
import { HttpError, readJsonBody, readRawBody, sendEmpty, sendJson, sendStatic } from './http.js';
|
||||
import { createRouter } from './router.js';
|
||||
import { seedWiki } from './services/wiki-seed.js';
|
||||
import { ROOT_PAGES, seedWiki } from './services/wiki-seed.js';
|
||||
|
||||
/** HTTP server of the dashboard (M16-T01). */
|
||||
|
||||
@@ -73,8 +73,13 @@ export function createHandler({ client = null, setupOnly = false, startedAt = Da
|
||||
const isApi = pathname.startsWith('/api/') || pathname.startsWith('/auth/');
|
||||
if (!isApi) {
|
||||
// The wiki is a separate public page: it must never fall back to the
|
||||
// dashboard shell, which would send a visitor to a login screen.
|
||||
const fallback = pathname === '/wiki' || pathname.startsWith('/wiki/') ? 'wiki.html' : 'index.html';
|
||||
// dashboard shell, which would send a visitor to a login screen. The
|
||||
// legal pages answer at the root, where platforms expect them.
|
||||
const isWiki =
|
||||
pathname === '/wiki' ||
|
||||
pathname.startsWith('/wiki/') ||
|
||||
ROOT_PAGES.includes(pathname.replace(/^\/|\/$/g, ''));
|
||||
const fallback = isWiki ? 'wiki.html' : 'index.html';
|
||||
const served = await sendStatic(response, publicDir, pathname, { fallback, request });
|
||||
if (!served) sendEmpty(response, 404);
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user