fix bun dev not starting correctly.
This commit is contained in:
+13
-4
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user