diff --git a/server.js b/server.js index 3385e09..3badb49 100644 --- a/server.js +++ b/server.js @@ -52,8 +52,9 @@ http.createServer(async (req, res) => { return res.end(JSON.stringify({ ok: true, id: rec.id })); } - const safe = decodeURIComponent(url); - const full = path.join(__dirname, safe); + const safe = decodeURIComponent(url) || "/"; + let file = safe === "/" ? "/index.html" : safe; + const full = path.join(__dirname, file); if (full.startsWith(__dirname) && fs.existsSync(full) && fs.statSync(full).isFile()) { const ext = path.extname(full).toLowerCase(); const types = { ".css": "text/css", ".js": "application/javascript", ".html": "text/html", ".png": "image/png", ".svg": "image/svg+xml", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp", ".ico": "image/x-icon" };