question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Worker cannot be imported from different origin.

See original GitHub issue

What are you trying to achieve? Please describe.

I have a web page under domain.com that uses a CDN for the JS files, the problem is that the origin is different then when I tri to import the worker Chrome says: Uncaught DOMException: Failed to construct ‘Worker’ ‘https://cdn.com’ cannot be accessed from origin ‘https:domain.com’ and CORS are well configured.

I’m using this import import { Document } from 'react-pdf/dist/esm/entry.webpack';

This is not happening in Firefox

Describe solutions you’ve tried

I tried to use a subdomain for the CDN like cdn.domain.com but not working neither.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
wojtekmajcommented, Nov 1, 2020

Well, you shouldn’t do that. Loading scripts from different origins is usually a bad idea.

2reactions
vijayapalponramcommented, Oct 30, 2020

Am also facing the same kind of error while loading the worker from different origin. image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Execute web worker from different origin - Stack Overflow
A solution would be to place the worker on www.myotherdomain.com or place a proxy file (which simply loads the worker from the cdn...
Read more >
Cross domain and cross browser web workers
You are limited by the same origin policy i.e. the worker script must be served from the same domain (including the protocol) as...
Read more >
Chapter 13 - Country of Origin Marking
Canada, Mexico and the United States shall exempt from country of origin marking requirements a good of another NAFTA country that: is a...
Read more >
Service Workers - W3C
A user agent may enable many service worker registrations at a single origin so long as the scope url of the service worker...
Read more >
Cross-Browser support with Cross-Origin isolation
Let's explore the journey of cross-origin isolation together. ... inside a Web Worker and importing a script with a script tag.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found