Skip to content

Commit

Permalink
fix: upload client does not need cors mode on presigned url put (#1295)
Browse files Browse the repository at this point in the history
Apparently some fetch implementations may not have "mode", which is the
case for Cloudflare Workers for instance. CF worker deploying
upload-client is now failing because this "mode" is set. You can also
read more about the general problem in
aws/aws-sdk-js-v3#1165

In summary, "mode" may not be implemented in fetch, but the default
appears to be cors anyway so this could be deleted without loss of
functionality:
https://developer.mozilla.org/en-US/docs/Web/API/Request/mode#default_mode.

Related to #1273
  • Loading branch information
vasco-santos authored Jan 31, 2024
1 parent 0337426 commit ef70a2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 0 additions & 1 deletion packages/upload-client/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export async function add(
try {
const res = await fetchWithUploadProgress(responseAddUpload.url, {
method: 'PUT',
mode: 'cors',
body: car,
headers: responseAddUpload.headers,
signal: options.signal,
Expand Down
7 changes: 7 additions & 0 deletions packages/w3up-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ This library is the user-facing "porcelain" client for interacting with w3up ser
- [Client-server](#client-server)
- [Delegated](#delegated)
- [User owned](#user-owned)
- [Environments requiring wasm import](#environments-requiring-wasm-imports)
- [API](#api)
- [Contributing](#contributing)
- [License](#license)
Expand Down Expand Up @@ -395,6 +396,12 @@ sequenceDiagram
- There is a world of possibilities with your users "bringing their own identity" for their Space; you could explore how crypto wallet private keys, Apple Passkey, and more might map to Space DIDs and have the client use those
- If you have code snippet(s) that works for you, please share them in a PR or [Github issue](https://github.com/web3-storage/w3up/issues) and we'll link them here!

### Environments requiring wasm import

Some environments (for instance Cloudflare Workers) require wasm bytecode to be imported. All other paths to load wasmm are disallowed by embedder. For these use cases, the default export of `w3up-client` (most compatible) won't work out of the box. A custom build will need to be created to get the client working.

We created a `esbuild-plugin` [esbuild-plugin-w3up-client-wasm-import](https://github.com/vasco-santos/esbuild-plugin-w3up-client-wasm-import) that you can easily use. There is also an [example repository](https://github.com/vasco-santos/worker-w3up-client-example).

## API

- [`create`](#create)
Expand Down

0 comments on commit ef70a2b

Please sign in to comment.