Skip to content

HTML preview allows rpf.io scripts but browser blocks them with CORS #1382

@adrian-rpf

Description

@adrian-rpf

Expected behaviour

  • It should be possible to load external scripts that are loaded via the rpf.io domain.
  • If external scripts are supported, they should load without an unexpected browser CORS failure.
  • If external scripts are not supported, the runner should block them intentionally and report that clearly.

Actual behaviour

  • The HTML preview allows https://rpf.io/ as an external source, but when a project includes <script src="https://rpf.io/piratetalk"></script>, the browser blocks it with a CORS error.
  • This creates a mismatch between the app’s allowlist and actual runtime behavior.

Steps to reproduce

  1. Open http://localhost:3011/web-component.html.
  2. Load or paste an HTML project containing <script src="https://rpf.io/piratetalk"></script>. Example
  3. Click RUN button
  4. Check the browser console.
  5. Observe: Access to script at 'https://rpf.io/piratetalk' from origin 'http://localhost:3011' has been blocked by CORS policy...

Additional context

  • src/utils/externalLinkHelper.js includes https://rpf.io/ in allowedExternalLinks.
  • src/components/Editor/Runners/HtmlRunner/HtmlRunner.jsx rewrites src attributes and unconditionally adds crossorigin, including on <script> tags.
  • That causes the browser to enforce CORS on external classic scripts that may otherwise have loaded.

Suggested fixes:

  • Potential: Only add crossorigin for media/assets that need it, not <script> tags but this may cause more CORS issue with Google hosted jQuery which is currently hidden.

Risks

  • Removing crossorigin from <script> tags may make third-party scripts execute instead of fail.
  • Would increase the security risk of running remote untrusted code.

Screenshots and Videos

Image

Once a fix is in, include a video on how to test it below

We're exploring using videos to demonstrate how to test new features, to improve our testing process.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions