feat(web/api): support PATCH on proxy and CORS

The web bundle proxy handled GET/POST/PUT/DELETE but not PATCH or
preflight OPTIONS, which broke browser calls to PATCH endpoints behind
the static-bundle server. CORS middleware had the same gap.
This commit is contained in:
2026-04-21 10:23:55 -04:00
parent 1b29a7692c
commit 542637c0dc
2 changed files with 13 additions and 1 deletions

View File

@@ -67,6 +67,18 @@ def register(app: typer.Typer) -> None:
return return
self.send_error(405) self.send_error(405)
def do_PATCH(self):
if self.path.startswith("/api/"):
self._proxy("PATCH")
return
self.send_error(405)
def do_OPTIONS(self):
if self.path.startswith("/api/"):
self._proxy("OPTIONS")
return
self.send_error(405)
def _proxy(self, method: str) -> None: def _proxy(self, method: str) -> None:
content_length = int(self.headers.get("Content-Length", 0)) content_length = int(self.headers.get("Content-Length", 0))
body = self.rfile.read(content_length) if content_length else None body = self.rfile.read(content_length) if content_length else None

View File

@@ -146,7 +146,7 @@ app.add_middleware(
CORSMiddleware, CORSMiddleware,
allow_origins=DECNET_CORS_ORIGINS, allow_origins=DECNET_CORS_ORIGINS,
allow_credentials=False, allow_credentials=False,
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"], allow_methods=["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
allow_headers=["Authorization", "Content-Type", "Last-Event-ID"], allow_headers=["Authorization", "Content-Type", "Last-Event-ID"],
) )