diff --git a/server.js b/server.js index c5b84ba..eefb461 100644 --- a/server.js +++ b/server.js @@ -48,12 +48,10 @@ function injectEnv(html) { // Serve .html with env injection; everything else statically. app.use((req, res, next) => { - let pathname; - try { - pathname = decodeURIComponent(req.path); - } catch { - return next(); - } + // Express resolves req.path to a decoded path (e.g. %E0%B8%A1 -> ม). + // Do NOT decodeURIComponent again — decoding twice breaks UTF-8 filenames, + // which made URL-encoded links (from the original site) 404 and lose their CSS. + const pathname = req.path; if (pathname.endsWith('.html') || pathname === '/' || !/\.[a-z0-9]+$/i.test(pathname)) { let file = pathname === '/' ? 'index.html' : pathname; let abs = join(DIST, file);