Fix HTML serving: use Bun.file() instead of HTMLBundle import
All checks were successful
Build and Push Frontend / build (push) Successful in 4s
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:
30
server.ts
30
server.ts
@@ -1,5 +1,3 @@
|
|||||||
import index from './public/index.html'
|
|
||||||
|
|
||||||
const PORT = process.env.PORT || 3001
|
const PORT = process.env.PORT || 3001
|
||||||
const BACKEND_URL = process.env.BACKEND_URL || 'http://localhost:3000'
|
const BACKEND_URL = process.env.BACKEND_URL || 'http://localhost:3000'
|
||||||
|
|
||||||
@@ -43,26 +41,18 @@ Bun.serve({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Serve static files from public directory
|
// Serve static files from public directory
|
||||||
if (url.pathname !== '/' && !url.pathname.includes('.')) {
|
const staticFile = Bun.file(`./public${url.pathname}`)
|
||||||
// SPA routing - serve index.html for all non-file routes
|
if (await staticFile.exists()) {
|
||||||
return new Response(index, {
|
return new Response(staticFile)
|
||||||
headers: {
|
|
||||||
'Content-Type': 'text/html',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serve index.html for root
|
// For all other routes (SPA routing), serve index.html
|
||||||
if (url.pathname === '/') {
|
const indexFile = Bun.file('./public/index.html')
|
||||||
return new Response(index, {
|
return new Response(indexFile, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'text/html',
|
'Content-Type': 'text/html',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
// Let Bun handle other static files
|
|
||||||
return new Response('Not Found', { status: 404 })
|
|
||||||
},
|
},
|
||||||
development: {
|
development: {
|
||||||
hmr: true,
|
hmr: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user