0

I'm learning about web workers from this site and following the example, but I keep getting this error. What does this mean? Both my index.html and pi.js files are saved on my desktop.

index.html:9 Uncaught SecurityError: Failed to construct 'Worker': Script at 'file:///Users/jlei/Desktop/pi.js' cannot be accessed from origin 'null'.

akantoword
  • 2,534
  • 7
  • 24
  • 39

2 Answers2

0

I would bet you can't do that just locally. Though I'm not all sure.. Have you tried in LAMP or similar or even on actual webspace?

https://en.wikipedia.org/wiki/LAMP_(software_bundle)

https://sourceforge.net/projects/wampserver/

0

If your project has a tsconfig, you probably need another tsconfig for the worker thread. Here is an example for Agular. it is Angular 8, but I tried it in Agular 14 and it still works

https://www.tutorialspoint.com/angular8/angular8_web_workers.htm

William
  • 449
  • 4
  • 9