[object Object]

← back to Ticket Action Viewer

Serve public/ static assets (nav-agent js/css) — raw http had no static route, so /nav-agent/* 404'd; add traversal-guarded handler before the 404

dc11065e7c0e7ad7efe9cdae6085ba02566e2808 · 2026-08-13 11:55:21 -0700 · Steve Abrams

Files touched

Diff

commit dc11065e7c0e7ad7efe9cdae6085ba02566e2808
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Thu Aug 13 11:55:21 2026 -0700

    Serve public/ static assets (nav-agent js/css) — raw http had no static route, so /nav-agent/* 404'd; add traversal-guarded handler before the 404
---
 server.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/server.js b/server.js
index 73f5fc3..a15be79 100644
--- a/server.js
+++ b/server.js
@@ -178,6 +178,18 @@ const server = http.createServer(async (req, res) => {
     if (action === 'done' || action === 'block') clearStart(short);   // leaving doing → stop the timer
     return json(res, 200, r);
   }
+  // ── static files under public/ (nav-agent asset, etc.) — traversal-guarded ──
+  // Raw http has no framework static middleware, so serve public/* here before the 404.
+  if (req.method === 'GET') {
+    const PUBLIC = path.join(__dirname, 'public');
+    const rel = decodeURIComponent(u.pathname).replace(/^\/+/, '');
+    const fp = path.normalize(path.join(PUBLIC, rel));
+    if (fp.startsWith(PUBLIC + path.sep) && fs.existsSync(fp) && fs.statSync(fp).isFile()) {
+      const TYPES = { '.js': 'application/javascript', '.css': 'text/css', '.html': 'text/html', '.json': 'application/json', '.svg': 'image/svg+xml', '.png': 'image/png', '.jpg': 'image/jpeg', '.ico': 'image/x-icon', '.woff2': 'font/woff2' };
+      res.writeHead(200, { 'Content-Type': TYPES[path.extname(fp)] || 'application/octet-stream' });
+      return res.end(fs.readFileSync(fp));
+    }
+  }
   res.writeHead(404); res.end('nf');
 });
 server.listen(PORT, () => console.log(`Ticket Action Viewer → http://127.0.0.1:${PORT} (admin/DW2024!)`));

← 76fc7f9 nav-agent: universal grid-controls drop-in on internal dashb  ·  back to Ticket Action Viewer  ·  Move default PORT 9971->10075 (9971 collided with gmc-viewer 917906c →