mirror of
https://github.com/langgenius/dify.git
synced 2026-03-16 04:17:43 +08:00
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.
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user