nostr-dev-kit / ndk

Nostr Development Kit with outbox-model support
https://nostr-dev-kit.github.io/ndk/
MIT License
366 stars 99 forks source link

NIP-96 uploads fail even when successful #273

Open twenty-eighty opened 1 month ago

twenty-eighty commented 1 month ago

Uploading files with Nip96.upload fail because of too strict status code handling. (tested with different servers)

The error:

Error uploading file: Error: Failed to upload file to https://files.sovbit.host/api/v2/media
    at Nip96.upload (index.mjs:7954:13)
    at async Object.onUpload (Editor.js:122:56)

The answer of the server:

Request URL: https://files.sovbit.host/api/v2/media
Request Method: POST
Status Code: 202 Accepted

The code that checks for the status code:

    if (res.status !== 200)
      throw new Error(`Failed to upload file to ${url}`);