diff --git a/playgrounds/demo/server.js b/playgrounds/demo/server.js index 0a545e7397..82a75e70e7 100644 --- a/playgrounds/demo/server.js +++ b/playgrounds/demo/server.js @@ -1,3 +1,4 @@ +// @ts-check import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -22,7 +23,10 @@ async function createServer() { app.use('*', async (req, res) => { if (req.originalUrl !== '/') { - res.sendFile(path.resolve('./dist' + req.originalUrl)); + res.writeHead(200, { + 'Content-Type': 'application/javascript' + }); + res.end(fs.createReadStream(path.resolve('./dist' + req.originalUrl))); return; } @@ -34,7 +38,7 @@ async function createServer() { .replace(``, appHtml) .replace(``, headHtml); - res.status(200).set({ 'Content-Type': 'text/html' }).end(html); + res.writeHead(200, { 'Content-Type': 'text/html' }).end(html); }); return { app, vite };