source: Klonkt/src/server.js@ fe9164f

main
Last change on this file since fe9164f was fe9164f, checked in by Robin Genis <roboburr@…>, 2 months ago

chore(csp): default-src 'none' (deny by default) + explicit manifest-src/worker-src

Tightens CSP to deny-by-default; the PWA manifest + service worker (previously covered by the
implicit default-src 'self') are listed explicitly so they keep working.

  • Property mode set to 100644
File size: 23.0 KB
Line 
1/**
2 * Klonkt Beta — server bootstrap
3 *
4 * Personal multi-site platform — Node + SQLite + htmx.
5 * Stack: Express + better-sqlite3 + EJS + htmx + ws.
6 */
7
8import 'dotenv/config';
9import express from 'express';
10import helmet from 'helmet';
11import session from 'express-session';
12import bodyParser from 'body-parser';
13import path from 'path';
14import fs from 'fs';
15import crypto from 'crypto';
16import { fileURLToPath } from 'url';
17import http from 'http';
18import db, { initializeDatabase } from './config/database.js';
19import { startScheduler } from './services/Scheduler.js';
20import { SqliteSessionStore } from './services/SqliteSessionStore.js';
21import { ensurePrimarySite } from './services/ensurePrimarySite.js';
22import { resolveSite, loadAudioTracks, loadTheme } from './middleware/site.js';
23import { isViewer } from './middleware/auth.js';
24import { renderPage } from './middleware/render.js';
25import { audioEnabled } from './config/features.js';
26import authRoutes from './routes/auth.js';
27import accountRoutes from './routes/account.js';
28import adminRoutes from './routes/admin.js';
29import adminAudioRoutes from './routes/admin-audio.js';
30import adminPlaylistsRoutes from './routes/admin-playlists.js';
31import adminSitesRoutes from './routes/admin-sites.js';
32import adminUsersRoutes from './routes/admin-users.js';
33import adminSettingsRoutes from './routes/admin-settings.js';
34import adminSeoRoutes from './routes/admin-seo.js';
35import audioRoutes from './routes/audio.js';
36import searchRoutes from './routes/search.js';
37import tagsRoutes from './routes/tags.js';
38import typesRoutes from './routes/types.js';
39import usersRoutes from './routes/users.js';
40import feedRoutes from './routes/feed.js';
41import postsRoutes from './routes/posts.js';
42import langRoutes from './routes/lang.js';
43import adminUpdatesRoutes from './routes/admin-updates.js';
44import adminPatreonRoutes from './routes/admin-patreon.js';
45import adminStatsRoutes from './routes/admin-stats.js';
46import circleRoutes from './routes/circle.js';
47import epkRoutes from './routes/epk.js';
48import newsletterRoutes from './routes/newsletter.js';
49import adminNewsletterRoutes from './routes/admin-newsletter.js';
50import downloadRoutes from './routes/download.js';
51import linkbioRoutes from './routes/linkbio.js';
52import embedRoutes from './routes/embed.js';
53import showsRoutes from './routes/shows.js';
54import adminShowsRoutes from './routes/admin-shows.js';
55import adminEpkRoutes from './routes/admin-epk.js';
56import changelogRoutes from './routes/changelog.js';
57import ogRoutes from './routes/og.js';
58import apRoutes from './routes/activitypub.js';
59import { apWants, startDeliveryWorker, selfHealTimeline } from './services/ActivityPubService.js';
60
61// SESSION_SECRET: use the env var if set. Otherwise auto-generate a strong one
62// and persist it next to the database, so it stays stable across restarts and
63// updates. This lets Docker / bare-Node installs run with zero manual config.
64if (!process.env.SESSION_SECRET) {
65 const dataDir = path.dirname(process.env.DATABASE_PATH || './storage/database.sqlite');
66 const secretFile = path.join(dataDir, '.session-secret');
67 try { process.env.SESSION_SECRET = fs.readFileSync(secretFile, 'utf8').trim(); } catch { /* not yet generated */ }
68 if (!process.env.SESSION_SECRET) {
69 fs.mkdirSync(dataDir, { recursive: true });
70 process.env.SESSION_SECRET = crypto.randomBytes(32).toString('hex');
71 fs.writeFileSync(secretFile, process.env.SESSION_SECRET, { mode: 0o600 });
72 console.log(`🔑 Generated a SESSION_SECRET (stored in ${secretFile})`);
73 }
74}
75
76// A SESSION_SECRET that was explicitly set in the env must still be strong in prod.
77if (process.env.NODE_ENV === 'production' && process.env.SESSION_SECRET.length < 32) {
78 console.error('❌ FATAL: SESSION_SECRET is too weak for production (set a longer, random one in .env)');
79 process.exit(1);
80}
81
82const __dirname = path.dirname(fileURLToPath(import.meta.url));
83const PORT = process.env.PORT || 3000;
84// Interface to bind. Default 0.0.0.0 (needed for Docker port-forwarding). Behind a
85// reverse proxy on the same host, set HOST=127.0.0.1 so the app is NOT reachable
86// directly from the internet (only via the proxy) — see README/install docs.
87const HOST = process.env.HOST || '0.0.0.0';
88const isDev = process.env.NODE_ENV !== 'production';
89
90const app = express();
91const server = http.createServer(app);
92
93// Per-request CSP nonce for the strict script-src (nonce + strict-dynamic). Must be set
94// before helmet builds the CSP header below. The nonce is injected into every <script> tag
95// at render time (see middleware/render.js injectCspNonce).
96app.use((req, res, next) => { res.locals.cspNonce = crypto.randomBytes(16).toString('base64'); next(); });
97
98app.use(helmet({
99 contentSecurityPolicy: {
100 directives: {
101 defaultSrc: ["'none'"],
102 // Strict CSP: a per-request nonce + 'strict-dynamic' (no 'unsafe-inline', no broad host
103 // sources — securityheaders/Observatory flag those). Trusted (nonce'd) scripts may load
104 // further scripts, which covers htmx-swapped inline scripts AND the external player APIs
105 // that embed-player.js injects (YouTube/SoundCloud/Spotify). The nonce is added to every
106 // <script> tag at render time (middleware/render.js injectCspNonce).
107 scriptSrc: [
108 "'strict-dynamic'",
109 (req, res) => `'nonce-${res.locals.cspNonce}'`,
110 ],
111 // Helmet's default sets script-src-attr to 'none', which blocks ALL inline
112 // event handlers (onchange/onclick/onsubmit) — causing e.g. the avatar
113 // upload (<input onchange="this.form.submit()">) and the role dropdown to
114 // silently do nothing. We explicitly allow inline handlers, consistent with
115 // the already-allowed inline <script> above.
116 scriptSrcAttr: ["'unsafe-inline'"],
117 styleSrc: ["'self'", "'unsafe-inline'"],
118 // blob: required for the image editor (Cropper) — it displays the chosen
119 // photo via URL.createObjectURL(blob:…). Without blob: the CSP silently
120 // blocks the <img> → empty edit window. (media-src already has blob: for audio.)
121 imgSrc: ["'self'", "data:", "https:", "blob:"],
122 connectSrc: ["'self'", "wss:", "ws:", "https://*.spotifycdn.com", "https://*.scdn.co"],
123 // blob: is required for the audio player — it fetch()es track bytes and
124 // plays from a blob: object URL (Spotify-style). Without blob: here the
125 // CSP silently blocks <audio>.src = blob:… → the player fires 'error' and
126 // auto-skips every track. 'self'/https: do NOT imply blob:.
127 mediaSrc: ["'self'", "https:", "blob:"],
128 fontSrc: ["'self'"],
129 // Embeds (platform players + cross-site Klonkt audio players) are framed broadly:
130 // ANY https origin, so embeds work in any context (feed, htmx/PWA nav, public pages).
131 // The sensitive /authorize_interaction page tightens frame-src back to 'self' in
132 // renderPage — it shows untrusted remote content next to the interact buttons.
133 frameSrc: ["'self'", "https:"],
134 // default-src is 'none' (deny by default), so resource types that were implicitly covered
135 // by the old default-src 'self' must be listed explicitly: the PWA manifest and the
136 // service worker. (base-uri/form-action/frame-ancestors/object-src 'none' come from
137 // Helmet's defaults; img/style/connect/media/font/frame are set above.)
138 manifestSrc: ["'self'"],
139 workerSrc: ["'self'", "blob:"],
140 },
141 },
142 hsts: { maxAge: 31536000, includeSubDomains: true, preload: true },
143 frameguard: { action: 'sameorigin' },
144 referrerPolicy: { policy: 'strict-origin-when-cross-origin' },
145}));
146
147app.set('view engine', 'ejs');
148app.set('views', path.join(__dirname, 'views'));
149
150app.use(bodyParser.urlencoded({ extended: true, limit: '10mb' }));
151app.use(bodyParser.json({ limit: '10mb' }));
152
153// Trust one upstream proxy in production. NPM (or Caddy / nginx) terminates
154// HTTPS and forwards to us over plain HTTP, setting X-Forwarded-Proto: https.
155// Without this, Express sees req.protocol === 'http' and won't issue secure
156// cookies — sessions never persist past the redirect after login.
157if (!isDev) app.set('trust proxy', 1);
158
159// Collapse leading duplicate slashes in the path. A reverse proxy that proxies with
160// `RewriteRule ^(.*)$ http://localhost:3000/$1` (Apache [P]) sends "//" for the root and
161// "//path" for sub-paths (the captured $1 keeps its leading slash) → Express matches no
162// route → the whole site 404'd behind such a proxy. Normalising here makes Klonkt resilient
163// to that common reverse-proxy setup. (Only the leading slashes; the query string is intact.)
164app.use((req, res, next) => {
165 if (req.url.startsWith('//')) req.url = req.url.replace(/^\/+/, '/');
166 next();
167});
168
169// Create/migrate the schema BEFORE anything touches the DB: the session store
170// queries the `sessions` table on construction, so on a fresh install the tables
171// must exist first (otherwise: "no such table: sessions" → crash loop on first boot).
172initializeDatabase();
173startScheduler(); // release planning: publish scheduled posts when publish_at is reached
174startDeliveryWorker(); // retry failed fediverse deliveries with backoff
175selfHealTimeline(); // once per SELFHEAL_VERSION bump: re-sync the fediverse cache (covers/edits) after a drastic update
176
177// Safety net: guarantee that there is always a primary site (solo/hub/circle).
178// Idempotent — does nothing if a site already exists or there is no admin yet.
179ensurePrimarySite();
180
181// Session middleware extracted into a variable so the WebSocket upgrade
182// handler can reuse it (it needs req.session to authenticate sockets).
183const sessionMiddleware = session({
184 store: new SqliteSessionStore(),
185 secret: process.env.SESSION_SECRET,
186 resave: false,
187 saveUninitialized: false,
188 name: 'pcms.sid',
189 cookie: {
190 httpOnly: true,
191 secure: !isDev,
192 sameSite: 'lax',
193 maxAge: 30 * 24 * 60 * 60 * 1000,
194 },
195});
196app.use(sessionMiddleware);
197
198app.use('/assets', express.static(path.join(__dirname, 'assets'), { maxAge: isDev ? 0 : '1y' }));
199app.use('/media', express.static(process.env.MEDIA_PATH || './storage/media', {
200 // Public media (post covers, avatars) must be cross-origin embeddable by other
201 // Klonkt sites in their CIRCLE. Helmet sets CORP=same-origin by default, which
202 // causes the browser to block those images (the file arrives, but the browser
203 // refuses to render it). Set cross-origin explicitly for /media.
204 setHeaders: (res) => res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin'),
205}));
206
207// (Removed) TWA / digital-asset-links — only needed for the APK/TWA variant.
208// Klonkt is PWA-only; assetlinks.json is no longer served.
209
210// Bundle HTMX: copy from node_modules into our own assets dir so we can serve
211// it locally (no third-party CDN). Idempotent — only copies if size differs.
212(function ensureLocalHtmx() {
213 const src = path.join(__dirname, '..', 'node_modules', 'htmx.org', 'dist', 'htmx.min.js');
214 const dest = path.join(__dirname, 'assets', 'js', 'htmx.min.js');
215 try {
216 const srcStat = fs.statSync(src);
217 const destStat = fs.existsSync(dest) ? fs.statSync(dest) : null;
218 if (!destStat || destStat.size !== srcStat.size) {
219 fs.copyFileSync(src, dest);
220 console.log(`📦 HTMX bundled locally: ${srcStat.size} bytes`);
221 }
222 } catch (e) {
223 console.warn('⚠️ Could not bundle HTMX:', e.message, '— run `npm install`');
224 }
225})();
226
227// ActivityPub: WebFinger + /ap/* (site-agnostic, resolves the site by slug).
228app.use(apRoutes);
229
230// Themed OG cards (/og/:slug.png) — resolve the site by slug themselves, so they
231// run before resolveSite and need no site context.
232app.use('/og', ogRoutes);
233
234app.use(resolveSite);
235app.use(loadAudioTracks);
236app.use(loadTheme);
237
238// ActivityPub content negotiation on the human URLs: an AP request (Accept:
239// application/activity+json) to a profile/post URL is redirected to its /ap/*
240// representation — same URL serves HTML to browsers, AP-JSON to servers (this is
241// how Mastodon resolves a pasted profile/post URL). Gated on apWants() so normal
242// browser requests pay nothing.
243app.use((req, res, next) => {
244 if (req.method !== 'GET' || !apWants(req)) return next();
245 const site = res.locals.site;
246 if (!site || !site.slug) return next();
247 const seg = req.path.replace(/^\/+|\/+$/g, '');
248 if (seg === '') return res.redirect(302, `/ap/users/${encodeURIComponent(site.slug)}`);
249 if (!seg.includes('/')) {
250 try {
251 const post = db.prepare(
252 "SELECT id FROM posts WHERE site_id = ? AND slug = ? AND status = 'published' AND (fan_only IS NULL OR fan_only = 0)"
253 ).get(site.id, seg);
254 if (post) return res.redirect(302, `/ap/notes/${post.id}`);
255 } catch { /* fall through to normal HTML handling */ }
256 }
257 return next();
258});
259
260// Lightweight CSRF defense: reject cross-origin state-mutating requests.
261// Same-origin forms + HTMX send a matching Origin; missing Origin is allowed
262// through (non-browser clients). sameSite:'lax' on the session cookie is the
263// second layer. (Does not apply to GET/HEAD/OPTIONS.)
264app.use((req, res, next) => {
265 if (req.method === 'GET' || req.method === 'HEAD' || req.method === 'OPTIONS') return next();
266 const origin = req.get('origin');
267 if (!origin) return next(); // no Origin → no browser CSRF vector
268 let originHost;
269 try { originHost = new URL(origin).host; } catch { return res.status(403).send('Ongeldige origin'); }
270 // Behind a reverse proxy the raw Host is the backend bind (e.g. localhost:3000, when the
271 // proxy doesn't preserve it — common with Apache .htaccess proxying), so also accept the
272 // operator-configured PUBLIC_BASE_URL host and the proxy's X-Forwarded-Host. Both are
273 // operator/proxy-controlled and can't be forged via a victim's browser, so this is safe.
274 const allowedHosts = [req.get('host'), req.get('x-forwarded-host')];
275 if (process.env.PUBLIC_BASE_URL) { try { allowedHosts.push(new URL(process.env.PUBLIC_BASE_URL).host); } catch { /* ignore bad config */ } }
276 if (!allowedHosts.includes(originHost)) return res.status(403).send('Cross-origin request geweigerd');
277 next();
278});
279
280// Viewer accounts: may view everything (including Admin), change nothing. This is
281// the ONLY write gate — fail-closed, before all route handlers. Every state-mutating
282// method is rejected (the login POST sets the session after this guard, so it is
283// not affected). Instead of raw 403 text we render a clean page (or, for HTMX,
284// a swapped-in message).
285app.use((req, res, next) => {
286 const mutating = req.method !== 'GET' && req.method !== 'HEAD' && req.method !== 'OPTIONS';
287 if (mutating && isViewer(req.session?.user)) {
288 if (req.headers['hx-request'] === 'true') {
289 // htmx doesn't swap on 4xx; send 200 + retarget so the message appears in #pcms-main.
290 res.setHeader('HX-Retarget', '#pcms-main');
291 res.setHeader('HX-Reswap', 'innerHTML');
292 res.status(200);
293 } else {
294 res.status(403);
295 }
296 return renderPage(req, res, 'pages/viewer-blocked', {
297 pageTitle: 'Kijker-modus',
298 bodyClass: 'on-special',
299 });
300 }
301 next();
302});
303
304app.use('/auth', authRoutes);
305app.use('/account', accountRoutes);
306// NB: /notifications is the fediverse notifications page (in postsRoutes). The old
307// user-notifications route was removed — it collided with the fedi route after the
308// /meldingen -> /notifications rename, and the user-notifications system is dead.
309if (audioEnabled()) {
310 app.use('/admin/audio', adminAudioRoutes);
311 app.use('/admin/playlists', adminPlaylistsRoutes);
312}
313app.use('/admin/sites', adminSitesRoutes);
314app.use('/admin/users', adminUsersRoutes);
315app.use('/admin/settings', adminSettingsRoutes);
316app.use('/admin/seo', adminSeoRoutes);
317app.use('/admin/updates', adminUpdatesRoutes);
318app.use('/admin/patreon', adminPatreonRoutes);
319app.use('/admin/stats', adminStatsRoutes);
320app.use('/admin/newsletter', adminNewsletterRoutes);
321app.use('/admin/shows', adminShowsRoutes);
322app.use('/admin/epk', adminEpkRoutes);
323app.use('/admin', adminRoutes);
324if (audioEnabled()) app.use('/audio', audioRoutes);
325app.use('/search', searchRoutes);
326app.use('/tag', tagsRoutes);
327app.use('/type', typesRoutes);
328app.use('/users', usersRoutes);
329// Feed/sitemap routes are mounted at root because they're at well-known paths
330app.use('/', feedRoutes);
331app.use('/', circleRoutes); // /cirkel-feed (solo: next() -> postsRoutes)
332app.use('/', epkRoutes); // /pers perskit (premium; niet-premium: next() -> 404)
333app.use('/', newsletterRoutes); // /nieuwsbrief in/uitschrijven (premium; niet-premium: next())
334if (audioEnabled()) app.use('/', downloadRoutes); // /downloads + /download/:id (audio; lite: uit)
335app.use('/', linkbioRoutes); // /links link-in-bio + klikstats (premium)
336if (audioEnabled()) app.use('/', embedRoutes); // /embed inbedbare audiospeler (audio; lite: uit)
337app.use('/', showsRoutes); // /shows agenda + notify-me (premium)
338app.use('/', changelogRoutes); // /changelog publieke release-/wijzigingen-pagina
339app.use('/', langRoutes); // /lang/:code — interface-taal kiezen (vóór de catch-all)
340app.use('/', postsRoutes);
341
342app.get('/manifest.webmanifest', (req, res) => {
343 const site = res.locals.site;
344
345 // PWA scope: confines installed apps to ONE site. If a user is in the
346 // bedrijf1 PWA and clicks a link to /sites/bedrijf2/..., the browser will
347 // open it in a regular tab (out-of-scope) instead of within the PWA.
348 // Same applies to APK packaging — the WebView is locked to this scope.
349 //
350 // For path-mounted sites: scope = /sites/<slug>/
351 // For root/subdomain sites: scope = /
352 const base = res.locals.siteUrlBase || ''; // '' or '/sites/<slug>'
353 const scope = (base || '') + '/';
354 const startUrl = (base || '') + '/?source=pwa';
355
356 // A stable identity per site so installs don't collide (Chromium uses `id`).
357 // NB: changing the id orphans existing PWA installs (no migration carries an
358 // install across an id change) — anyone who already installed the site as a
359 // PWA will need to reinstall once. Data stays server-side, so nothing is lost.
360 const idBase = site?.slug ? `klonkt-${site.slug}` : 'klonkt';
361
362 res.set('Cache-Control', 'no-cache');
363 res.json({
364 id: idBase,
365 name: site?.title || 'Klonkt',
366 short_name: (site?.title || 'Klonkt').slice(0, 12),
367 description: site?.description || site?.tagline || '',
368 scope,
369 start_url: startUrl,
370 display: 'standalone',
371 display_override: ['standalone', 'minimal-ui'],
372 orientation: 'any',
373 background_color: '#1a1a17',
374 theme_color: site?.accent || '#e8b04b',
375 lang: site?.language || 'nl',
376 icons: [
377 { src: '/favicon.svg', sizes: 'any', type: 'image/svg+xml' },
378 { src: '/favicon.ico', sizes: '64x64', type: 'image/x-icon' },
379 ],
380 // Hint to capable browsers: capture all in-scope links inside the PWA
381 capture_links: 'existing-client-navigate',
382 });
383});
384
385// Favicon — served as SVG so it picks up the site's accent color dynamically.
386// Browsers also request /favicon.ico by convention; we serve the same SVG
387// content there with a forgiving content-type since modern browsers accept it.
388function _renderFavicon(res, accent) {
389 const safeAccent = /^#[0-9a-fA-F]{3,8}$/.test(accent) ? accent : '#e8b04b';
390 // Site mark: rounded square in the site accent + bold white 'K' (Klonkt)
391 const svg = `<?xml version="1.0" encoding="UTF-8"?>
392<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
393 <rect width="64" height="64" rx="14" fill="${safeAccent}"/>
394 <text x="50%" y="50%" dy="0.35em" text-anchor="middle"
395 font-family="Arial, Helvetica, sans-serif"
396 font-size="42" font-weight="800" fill="#fff">K</text>
397</svg>`;
398 res.set('Content-Type', 'image/svg+xml');
399 res.set('Cache-Control', 'public, max-age=86400');
400 res.send(svg);
401}
402
403app.get('/favicon.svg', (req, res) => {
404 _renderFavicon(res, res.locals.site?.accent);
405});
406app.get('/favicon.ico', (req, res) => {
407 // Browsers requesting .ico will accept SVG content; chrome/firefox both fine.
408 // Keeping the route prevents 404 spam in the console.
409 _renderFavicon(res, res.locals.site?.accent);
410});
411
412app.get('/sw.js', (req, res) => {
413 res.set('Content-Type', 'application/javascript');
414 res.set('Cache-Control', 'no-cache');
415 res.send(`
416const CACHE_VERSION = 'pcms-v16-' + new Date().toISOString().split('T')[0];
417self.addEventListener('install', e => {
418 e.waitUntil(caches.open(CACHE_VERSION).then(c => c.addAll(['/'])));
419 self.skipWaiting();
420});
421self.addEventListener('activate', e => {
422 e.waitUntil(caches.keys().then(keys => Promise.all(
423 keys.filter(k => k !== CACHE_VERSION).map(k => caches.delete(k))
424 )));
425 self.clients.claim();
426});
427// ONLY intercept navigations (HTML pages) for an offline fallback.
428// Do NOT touch images, CSS, JS or /media — let the browser handle those natively.
429// Otherwise a failed network fetch could fall back to an empty cache match
430// (undefined) and "break" an image on a normal refresh (hard reload bypasses
431// the SW, which is why that case worked fine).
432self.addEventListener('fetch', e => {
433 if (e.request.method !== 'GET') return;
434 if (e.request.mode !== 'navigate') return; // page loads only
435 // Same-origin ONLY. A cross-origin navigate request is an <iframe> embed
436 // (YouTube/Spotify/SoundCloud …) — routing those through the SW yields an
437 // opaque/altered response the iframe cannot render → blank embeds in the
438 // installed PWA (which is always SW-controlled). Let the browser load them.
439 try { if (new URL(e.request.url).origin !== self.location.origin) return; } catch (err) { return; }
440 e.respondWith(
441 fetch(e.request).catch(() => caches.match('/').then(r => r || Response.error()))
442 );
443});
444 `);
445});
446
447process.on('unhandledRejection', (reason) => {
448 console.error('⚠️ Unhandled Rejection:', reason);
449});
450
451app.use((err, req, res, next) => {
452 console.error('❌ Error:', err);
453 res.status(err.status || 500).send(
454 isDev ? `<pre>${err.stack || err.message}</pre>` : 'Internal Server Error'
455 );
456});
457
458app.use((req, res) => {
459 res.status(404);
460 // Clean, mobile-friendly 404 via the shell (viewport + nav + site theme).
461 // Falls back to bare HTML if rendering unexpectedly fails.
462 try {
463 return renderPage(req, res, 'pages/404', {
464 pageTitle: '404 — niet gevonden',
465 bodyClass: 'on-special on-404',
466 });
467 } catch (e) {
468 return res.send('<!doctype html><meta name="viewport" content="width=device-width,initial-scale=1"><div style="font-family:system-ui;max-width:500px;margin:4rem auto;text-align:center;padding:2rem"><h1 style="font-size:4rem;margin:0">404</h1><p>Pagina niet gevonden</p><a href="/">← Home</a></div>');
469 }
470});
471
472server.listen(PORT, HOST, () => {
473 const baseUrl = (process.env.PUBLIC_BASE_URL || '').replace(/\/+$/, '');
474 console.log('');
475 console.log('🪶 Klonkt');
476 console.log(` ${baseUrl || `http://localhost:${PORT}`}`);
477 if (baseUrl) console.log(` (bound to ${HOST}:${PORT})`);
478 console.log('');
479 console.log(` ✓ Security: Helmet, CSP, secure sessions`);
480 console.log(` ✓ Privacy: Self-hosted fonts, no third-party requests`);
481 console.log(` ✓ Layout: v9 editorial feel (top nav, profile header)`);
482 console.log(` ✓ Auth: wachtwoord (beheer) + Google (luisteraars) / logout`);
483 console.log(` ✓ Posts: create / edit / view / archive`);
484 console.log('');
485 console.log(` Mode: ${isDev ? 'development' : 'PRODUCTION'}`);
486 console.log('');
487});
488
489export default app;
Note: See TracBrowser for help on using the repository browser.