Fix HTML serving: use Bun.file() instead of HTMLBundle import
All checks were successful
Build and Push Frontend / build (push) Successful in 4s

Fixes [object HTMLBundle] error by properly reading HTML file

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hector Ros
2026-01-20 01:30:24 +01:00
parent 2a531e98ae
commit 137f1fe110

View File

@@ -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,