webcontainer-core icon indicating copy to clipboard operation
webcontainer-core copied to clipboard

CORS error on load

Open abdulk1 opened this issue 1 year ago • 2 comments
trafficstars

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

  • OS: macOS
  • Browser: Chrome
  • Version: 121

Additional context

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

abdulk1 avatar Feb 19 '24 22:02 abdulk1

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 ?

abdulk1 avatar Feb 19 '24 23:02 abdulk1

@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?

jrvidal avatar Feb 21 '24 12:02 jrvidal