| … | … | @@ -41,6 +41,16 @@ export function serveStatic (webDir, opts = {}) { |
| 41 | 41 | const urlPath = req.url.split('?')[0] |
| 42 | 42 | |
| 43 | 43 | // Serve files under prefix |
| 44 | if (urlPath === prefix || urlPath === prefix + '/') { | |
| 45 | // Prefix root → serve index.html | |
| 46 | try { | |
| 47 | const data = fs.readFileSync(indexPath) | |
| 48 | res.writeHead(200, { 'Content-Type': 'text/html', 'Content-Length': data.length }) | |
| 49 | res.end(data) | |
| 50 | return true | |
| 51 | } catch { return false } | |
| 52 | } | |
| 53 | ||
| 44 | 54 | if (urlPath.startsWith(prefix + '/')) { |
| 45 | 55 | const relPath = urlPath.slice(prefix.length) |
| 46 | 56 | const filePath = path.join(webDir, relPath) |