Skip to content

Commit 710b88d

Browse files
committed
fix
1 parent 4fbd46b commit 710b88d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

core/server/plugin/ui.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ export function addPlugin(app: Express, value: any, dir: string, fullName: strin
3434
// SPA fallback: serve index.html for non-file paths
3535
if (r.spa) {
3636
const indexPath = join(fsPath, "index.html");
37-
app.use(fullPrefix, (_req, res, next) => {
38-
try {
39-
res.sendFile(indexPath);
40-
} catch {
41-
next();
42-
}
43-
});
44-
console.log(`Registered SPA fallback: ${fullPrefix}/* -> ${indexPath}`);
37+
try {
38+
const html = Deno.readTextFileSync(indexPath);
39+
app.use(fullPrefix, (_req, res) => {
40+
res.type("html").send(html);
41+
});
42+
console.log(`Registered SPA fallback: ${fullPrefix}/* -> ${indexPath}`);
43+
} catch {
44+
console.warn(`SPA fallback skipped (index.html not found): ${indexPath}`);
45+
}
4546
}
4647
}
4748
}

0 commit comments

Comments
 (0)