stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.79k stars 145 forks source link

CORS error on load #1332

Open abdulk1 opened 7 months ago

abdulk1 commented 7 months ago

Describe the bug

I'm trying to use a WebContainer in a Chrome extension but receiving a CORS error due to Cross-Origin-Resource-Policy not set in the response from https://stackblitz.com/headless?version=1.1.9.

Link to the blitz that caused the error

https://github.com/abdulk1/web-extension

Steps to reproduce

Clone https://github.com/abdulk1/web-extension Open Chrome and go to chrome://extensions/ Click load unpacked Select dist folder Open new tab WebContainer tutorial doesn't fully load

Expected behavior

The Chrome extension should load successfully w/o the CORS error. Should operate similar to a web page

Parity with Local

Screenshots

image

Platform

Additional context

Aim is to get this tutorial setup as a Chrome extension. https://webcontainers.io/tutorial/1-build-your-first-webcontainer-app

abdulk1 commented 7 months ago

The same code works as a normal website, just seeing a CORS error when tried as a web extension.

Maybe chrome-extension:// needs to be added to the Access-Control-Allow-Origin for https://stackblitz.com/headless ?

jrvidal commented 7 months ago

@abdulk1 :wave: Thanks for the report! It's really cool that you're trying to get something going on with Chrome extensions.

I suspect the problem is that the embedded iframe is returning a 404. Can you check if a Referer header is being sent in the request for the extension iframe?