cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.6k stars 673 forks source link

🚀 Feature Request: use API proxy from WebContainers #1796

Open eidam opened 2 years ago

eidam commented 2 years ago

Describe the solution

StackBlitz WebContainers are running in the browser, therefor CORS is applied and forced. We can work around this by detecting when Wrangler runs in WebContainer and set a different base api URL. (https://api-proxy.r.workers.dev/client/v4/)

penalosa commented 2 years ago

What about (to make this slightly more generic) detecting when a request to the API fails because of CORs, and only then switching to the api proxy? (and perhaps caching that decision somewhere for future runs).

penalosa commented 2 years ago

Pretty sure I found a bug in the Stackblitz environment while investigating this, and so we'll see what they say: https://github.com/stackblitz/webcontainer-core/issues/807