workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

🚀 Feature Request: use API proxy from WebContainers

Open eidam opened this issue 3 years ago • 2 comments

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/)

eidam avatar Sep 08 '22 12:09 eidam

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 avatar Sep 08 '22 13:09 penalosa

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

penalosa avatar Sep 12 '22 17:09 penalosa