Skip to content

fix(s3): list bucket via plain fetch to avoid CORS preflight rejection#871

Open
PaulHax wants to merge 1 commit intoKitware:mainfrom
PaulHax:s3-listing-fetch
Open

fix(s3): list bucket via plain fetch to avoid CORS preflight rejection#871
PaulHax wants to merge 1 commit intoKitware:mainfrom
PaulHax:s3-listing-fetch

Conversation

@PaulHax
Copy link
Copy Markdown
Collaborator

@PaulHax PaulHax commented May 4, 2026

@aws-sdk/client-s3 attaches x-amz-content-sha256, x-amz-user-agent, amz-sdk-invocation-id, and amz-sdk-request headers, which force a CORS preflight. Buckets whose AllowedHeaders rule doesn't cover them reject the preflight, breaking s3:// URI loading even for public anonymous buckets (reproduced against IDC's idc-open-data and idc-open-data-two, issue #869).

Replace the SDK-driven ListObjectsV2Command with a plain fetch() of the same XML endpoint. The request becomes CORS-simple (no preflight), and the SDK dependency is dropped entirely.

  • Adds retry with exponential backoff and jitter (3 attempts) on transient 5xx / 408 / 429 / network errors.
  • Tests cover listing, pagination, retry, retry-exhaustion, and a no-custom-headers invariant guarding against regression.
  • @aws-sdk/client-s3 removed from devDependencies.

`@aws-sdk/client-s3` attaches `x-amz-content-sha256`, `x-amz-user-agent`,
`amz-sdk-invocation-id`, and `amz-sdk-request` headers, which force a CORS
preflight. Buckets whose `AllowedHeaders` rule doesn't cover them reject
the preflight, breaking `s3://` URI loading even for public anonymous
buckets (reproduced against IDC's `idc-open-data` and `idc-open-data-two`,
issue Kitware#869).

Replace the SDK-driven `ListObjectsV2Command` with a plain `fetch()` of the
same XML endpoint. The request becomes CORS-simple (no preflight), and the
SDK dependency is dropped entirely.

- Adds retry with exponential backoff and jitter (3 attempts) on transient
  5xx / 408 / 429 / network errors.
- Tests cover listing, pagination, retry, retry-exhaustion, and a
  no-custom-headers invariant guarding against regression.
- `@aws-sdk/client-s3` removed from devDependencies.
@netlify
Copy link
Copy Markdown

netlify Bot commented May 4, 2026

Deploy Preview for volview-dev ready!

Name Link
🔨 Latest commit 762b567
🔍 Latest deploy log https://app.netlify.com/projects/volview-dev/deploys/69f8ee79b111c1000882185c
😎 Deploy Preview https://deploy-preview-871--volview-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant