Skip to content

Conversation

@ilhan007
Copy link
Contributor

@ilhan007 ilhan007 commented Jan 9, 2026

Website samples run on localhost.

Fixes: #12878

Context

The samples were failing on Chrome and Safari (still working on Firefox) with CORS error as some playground* files are hosted on unpkg.com, while all the ui5 web components sample files are hosted locally. This is leading to errors like:

index.html:1 Access to script at 'http://localhost:3000/local-cdn/base/dist/locale/applyDirection.js' from origin 'https://unpkg.com/' has been blocked by CORS policy: Permission was denied for this request to access the `unknown` address space.

While this was not a problem so far, recent changes in Chrome restricted this behaviour as security issue. Chrome 142 restricts the ability to make requests to the user's local network. The main motivation is to avoid "CSRF attacks against vulnerable local devices, and generally abuse the user's browser as a "confused deputy" that has access inside the user's local network or software on their local machine".
Read more details here.

Solution

  • Copy the playground-worker files to the website/static folder
  • Make use of the sandboxBaseUrl property to configure the origin of the playground worker files (unpkg.com by default ) to localhost only on local development.
  const playgroundProject = document.createElement("playground-project");
  if (process.env.NODE_ENV === "development") {
      playgroundProject.sandboxBaseUrl = window.location.origin + "/";
  }

This way everything is hosted locally, fixing the CORS error.

@ilhan007 ilhan007 requested a review from pskelin January 9, 2026 15:29
@ui5-webcomponents-bot
Copy link
Collaborator

ui5-webcomponents-bot commented Jan 9, 2026

🧹 Preview deployment cleaned up: https://pr-12883--ui5-webcomponents.netlify.app

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview January 9, 2026 15:39 Inactive
@ilhan007 ilhan007 requested a review from nnaydenow January 9, 2026 16:18
@ilhan007 ilhan007 merged commit c7d9080 into main Jan 12, 2026
14 checks passed
@ilhan007 ilhan007 deleted the docs-fix-samples-on-localhost branch January 12, 2026 08:49
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview January 12, 2026 08:50 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[playground]: samples not loading

4 participants