Skip to content

feature(CORS): Remove CORS proxy for R2 parquet downloads in Pyodide#22

Merged
szemyd merged 1 commit intomainfrom
claude/fix-r2-cors-headers-y6d1b
Apr 14, 2026
Merged

feature(CORS): Remove CORS proxy for R2 parquet downloads in Pyodide#22
szemyd merged 1 commit intomainfrom
claude/fix-r2-cors-headers-y6d1b

Conversation

@szemyd
Copy link
Copy Markdown
Contributor

@szemyd szemyd commented Apr 14, 2026

Summary

This PR removes the CORS proxy layer for parquet file downloads in Pyodide/WASM environments. Parquet files are now downloaded directly from presigned R2 URLs, which have CORS headers configured on the R2 buckets to allow cross-origin GET requests from the browser.

Key Changes

  • Simplified download flow: Removed the proxy URL construction logic that routed requests through {base_url}/data/proxy
  • Direct R2 access: Parquet files are now fetched directly from presigned URLs using pyfetch(url, method="GET")
  • Removed unnecessary headers: Eliminated the _to_js_headers() conversion since presigned URLs carry authentication in query parameters (X-Amz-*) and don't require additional headers
  • Updated documentation: Module docstring and function docstring now reflect that CORS is configured on R2 buckets rather than proxied
  • Updated tests: Test cases now verify direct presigned URL fetching instead of proxy-based routing

Implementation Details

  • Presigned URLs from R2 include authentication via query parameters, eliminating the need for custom headers or proxy intermediaries
  • The change reduces latency by removing an extra hop through the proxy endpoint
  • CORS configuration on the R2 buckets handles cross-origin requests directly from browser environments

https://claude.ai/code/session_011sUKbmutP1bnrtk6yJgUUX

R2 buckets now have CORS configured to allow GET from the browser,
so presigned URLs can be fetched directly. This removes the extra
server hop that was streaming all parquet bytes through the app server.
@szemyd szemyd changed the title Remove CORS proxy for R2 parquet downloads in Pyodide feature(CORS): Remove CORS proxy for R2 parquet downloads in Pyodide Apr 14, 2026
@szemyd szemyd merged commit 79e8e4b into main Apr 14, 2026
20 checks passed
@szemyd szemyd deleted the claude/fix-r2-cors-headers-y6d1b branch April 14, 2026 15:19
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