From f8b27dd6624d372abd67ea31489d5351dd9dced0 Mon Sep 17 00:00:00 2001 From: yyh Date: Thu, 15 Jan 2026 10:54:42 +0800 Subject: [PATCH] fix(web): accept 2xx status codes in upload function for HTTP semantics The upload helper was hardcoded to only accept HTTP 201, which broke PUT requests that return 200. This aligns with standard HTTP semantics where POST returns 201 Created and PUT returns 200 OK. --- web/service/base.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/service/base.ts b/web/service/base.ts index fb32ce6bcf..956886bea9 100644 --- a/web/service/base.ts +++ b/web/service/base.ts @@ -396,7 +396,9 @@ export const upload = async (options: UploadOptions, isPublicAPI?: boolean, url? xhr.responseType = 'json' xhr.onreadystatechange = function () { if (xhr.readyState === 4) { - if (xhr.status === 201) + // Accept any 2xx status code per HTTP semantics + // POST returns 201 Created, PUT returns 200 OK + if (xhr.status >= 200 && xhr.status < 300) resolve(xhr.response) else reject(xhr)