chore: fix playground SSR (#12195)

pull/12182/head
Rich Harris 4 months ago committed by Dominic Gannaway
parent ef4b70ed2c
commit 12f1fe44f0

@ -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(`<!--ssr-html-->`, appHtml)
.replace(`<!--ssr-head-->`, headHtml);
res.end(html);
res.writeHead(200, { 'Content-Type': 'text/html' }).end(html);
});
return { app, vite };

Loading…
Cancel
Save