Building a CORS-Friendly PyPI Mirror on Cloudflare

Pyodide runs Python inside WebAssembly, using Micropip to fetch packages from PyPI. When running in a browser, Micropip has two strict requirements: proper CORS headers, and support for the JSON-based Simple API (PEP 691).

Direct access to PyPI from mainland China is often unreliable, but domestic mirrors present their own challenges. Mirrors like Alibaba Cloud, Tencent Cloud, and Huawei Cloud only serve the legacy HTML index. Tsinghua’s TUNA mirror supports PEP 691, but does not send CORS headers.

As a result, there were essentially zero domestic mirrors that Micropip could pull from directly inside the browser.

To bridge this gap, I set up a Cloudflare-based mirror that adds CORS headers and handles PEP 691 lookups.

You can deploy it using either Cloudflare Workers or Cloudflare Snippets:

Workers

Snippets

Code

The project is open source on GitHub:

https://github.com/ccbikai/cloudflare-pypi-mirror

Cloudflare PyPI Mirror

aria

© 2026 Aria

Instagram 𝕏 GitHub