Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"physi.js" causes the error: "Script cannot be accessed from origin 'null'"

I was trying to play with physi.js library (). I followed all the steps given:

https://github.com/chandlerprall/Physijs/wiki/Basic-Setup

However, I got the error:

Uncaught SecurityError: Failed to construct 'Worker': Script at 'file://172.16.159.200/js/physijs_worker.js' cannot be accessed from origin 'null'.

I tried to go deeper, and saw that the problem with the line:

this._worker = new Worker( Physijs.scripts.worker || 'physijs_worker.js' );

What did cause that issue? The browser is Google Chrome. I checked, the file "physijs_worker.js" appears in the right location.

like image 885
Darius Miliauskas Avatar asked May 12 '15 22:05

Darius Miliauskas


3 Answers

Browsers don't allow creating workers from local files because that would be a security issue.

See also this question:

Why does not Chrome allow Web Workers to be run in JavaScript?

like image 63
marsze Avatar answered Oct 29 '22 09:10

marsze


Just add the chrome extension https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb?hl=en

and use the extension to launch your index.html. As now it will be running in localhost, there will be no error

like image 3
Fast Mani Avatar answered Oct 29 '22 10:10

Fast Mani


Deploy your website on a web server. Without the web server I get the same error.

like image 3
Rendolf Avatar answered Oct 29 '22 09:10

Rendolf