| 219 | } |
| 220 | |
| 221 | async function sendIndexFallback(webDist: string, res: http.ServerResponse): Promise<void> { |
| 222 | const indexPath = path.join(webDist, "index.html"); |
| 223 | let stat: Awaited<ReturnType<typeof fsp.stat>>; |
| 224 | try { |
| 225 | stat = await fsp.stat(indexPath); |
| 226 | } catch { |
| 227 | res.writeHead(404, { "Content-Type": "text/plain" }); |
| 228 | res.end("Not Found"); |
| 229 | return; |
| 230 | } |
| 231 | res.writeHead(200, { |
| 232 | "Content-Type": "text/html; charset=utf-8", |
| 233 | "Content-Length": String(stat.size), |
| 234 | }); |
| 235 | await pipeline(createReadStream(indexPath), res); |
| 236 | } |