fix: handle API POST/PATCH/DELETE in fetch handler

Bun's routes object has issues with non-GET methods not being matched
correctly. Handle these methods explicitly in the fetch handler.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2025-12-04 05:23:25 -08:00
parent bcd3c30f92
commit d2a229ade2
1 changed files with 17 additions and 0 deletions

View File

@ -148,6 +148,23 @@ export class BacklogAggregator {
return new Response(htmlFile, { headers: { "Content-Type": "text/html" } }); return new Response(htmlFile, { headers: { "Content-Type": "text/html" } });
} }
// Handle API routes with non-GET methods (Bun routes object has issues with POST/PATCH/DELETE)
if (url.pathname.startsWith("/api/")) {
const method = req.method.toUpperCase();
if (url.pathname === "/api/tasks/update" && method === "PATCH") {
return this.handleUpdateTask(req);
}
if (url.pathname === "/api/tasks/create" && method === "POST") {
return this.handleCreateTask(req);
}
if (url.pathname === "/api/tasks/archive" && method === "POST") {
return this.handleArchiveTask(req);
}
if (url.pathname === "/api/tasks/delete" && method === "DELETE") {
return this.handleDeleteTask(req);
}
}
return new Response("Not Found", { status: 404 }); return new Response("Not Found", { status: 404 });
}, },
websocket: { websocket: {