fix bun dev not starting correctly.

This commit is contained in:
Lucas Winther
2026-07-14 12:38:24 +02:00
parent 2dff7512ac
commit e4be47f707
+13 -4
View File
@@ -178,7 +178,15 @@ async function developmentServeOptions(): Promise<ServeOptions> {
const scriptHeaders = { "Content-Type": "text/javascript; charset=utf-8" };
return {
async fetch(request) {
routes: {
// The HTML import is an HTMLBundle, which Bun only serves as a route
// value — returning it from fetch() throws "Expected a Response object".
"/": index,
},
// Fallback for everything the route table doesn't match, including
// subpath-proxied requests (/proxy/api/..., /proxy/sw.js, ...).
async fetch(request, server) {
const url = new URL(request.url);
const pathname = url.pathname;
@@ -204,9 +212,10 @@ async function developmentServeOptions(): Promise<ServeOptions> {
return serveOrtFile(ORT_DIST, ortMatch[1]);
}
// Serve the bundled React app for all other routes.
// In development, this is a special Response object from Bun's HTML bundler.
return index;
// SPA fallback: unknown navigations (including subpath ones) get the
// app shell. The HTMLBundle itself can only live in `routes`, so
// re-enter the server at "/" to let it produce the dev-bundled HTML.
return fetch(new URL("/", server.url));
},
development: {