Fix WebSocket upgrade by moving / route to fetch handler
Routes in Bun.serve() take precedence over WebSocket upgrade checks. Move the root path handler to the fetch() function so WebSocket upgrade requests are processed first. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
a3ad292b81
commit
3230156ada
|
|
@ -91,16 +91,7 @@ export class BacklogAggregator {
|
||||||
port: this.config.port,
|
port: this.config.port,
|
||||||
development: process.env.NODE_ENV === "development",
|
development: process.env.NODE_ENV === "development",
|
||||||
routes: {
|
routes: {
|
||||||
"/": async () => {
|
// NOTE: "/" route is handled in fetch() to allow WebSocket upgrade
|
||||||
const htmlPath = pathJoin(__dirname, "web", "index.html");
|
|
||||||
const htmlFile = Bun.file(htmlPath);
|
|
||||||
return new Response(htmlFile, { headers: { "Content-Type": "text/html" } });
|
|
||||||
},
|
|
||||||
"/app.tsx": async () => {
|
|
||||||
const tsxPath = pathJoin(__dirname, "web", "app.tsx");
|
|
||||||
const tsxFile = Bun.file(tsxPath);
|
|
||||||
return new Response(tsxFile, { headers: { "Content-Type": "application/javascript" } });
|
|
||||||
},
|
|
||||||
"/api/projects": {
|
"/api/projects": {
|
||||||
GET: async () => this.handleGetProjects(),
|
GET: async () => this.handleGetProjects(),
|
||||||
},
|
},
|
||||||
|
|
@ -138,6 +129,13 @@ export class BacklogAggregator {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Serve the HTML app for root path
|
||||||
|
if (url.pathname === "/" || url.pathname === "") {
|
||||||
|
const htmlPath = pathJoin(__dirname, "web", "index.html");
|
||||||
|
const htmlFile = Bun.file(htmlPath);
|
||||||
|
return new Response(htmlFile, { headers: { "Content-Type": "text/html" } });
|
||||||
|
}
|
||||||
|
|
||||||
return new Response("Not Found", { status: 404 });
|
return new Response("Not Found", { status: 404 });
|
||||||
},
|
},
|
||||||
websocket: {
|
websocket: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue