From e4be47f707fd5095977563d3220d4d8df9163506 Mon Sep 17 00:00:00 2001 From: Lucas Winther Date: Tue, 14 Jul 2026 12:38:24 +0200 Subject: [PATCH] fix bun dev not starting correctly. --- src/index.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 78a5391..63e51e1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -178,7 +178,15 @@ async function developmentServeOptions(): Promise { 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 { 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: {