Skip to content

Commit 12f1fe4

Browse files
Rich-Harristrueadm
authored andcommitted
chore: fix playground SSR (#12195)
1 parent ef4b70e commit 12f1fe4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

playgrounds/demo/server.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-check
12
import fs from 'node:fs';
23
import path from 'node:path';
34
import { fileURLToPath } from 'node:url';
@@ -22,7 +23,10 @@ async function createServer() {
2223

2324
app.use('*', async (req, res) => {
2425
if (req.originalUrl !== '/') {
25-
res.sendFile(path.resolve('./dist' + req.originalUrl));
26+
res.writeHead(200, {
27+
'Content-Type': 'application/javascript'
28+
});
29+
res.end(fs.createReadStream(path.resolve('./dist' + req.originalUrl)));
2630
return;
2731
}
2832

@@ -34,7 +38,7 @@ async function createServer() {
3438
.replace(`<!--ssr-html-->`, appHtml)
3539
.replace(`<!--ssr-head-->`, headHtml);
3640

37-
res.end(html);
41+
res.writeHead(200, { 'Content-Type': 'text/html' }).end(html);
3842
});
3943

4044
return { app, vite };

0 commit comments

Comments
 (0)