diff --git a/server.ts b/server.ts index 243278d..bcb2dc2 100644 --- a/server.ts +++ b/server.ts @@ -1,5 +1,3 @@ -import index from './public/index.html' - const PORT = process.env.PORT || 3001 const BACKEND_URL = process.env.BACKEND_URL || 'http://localhost:3000' @@ -43,26 +41,18 @@ Bun.serve({ } // Serve static files from public directory - if (url.pathname !== '/' && !url.pathname.includes('.')) { - // SPA routing - serve index.html for all non-file routes - return new Response(index, { - headers: { - 'Content-Type': 'text/html', - }, - }) + const staticFile = Bun.file(`./public${url.pathname}`) + if (await staticFile.exists()) { + return new Response(staticFile) } - // Serve index.html for root - if (url.pathname === '/') { - return new Response(index, { - headers: { - 'Content-Type': 'text/html', - }, - }) - } - - // Let Bun handle other static files - return new Response('Not Found', { status: 404 }) + // For all other routes (SPA routing), serve index.html + const indexFile = Bun.file('./public/index.html') + return new Response(indexFile, { + headers: { + 'Content-Type': 'text/html', + }, + }) }, development: { hmr: true,