Darius Miliauskas
Darius Miliauskas

Reputation: 3524

"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.

Upvotes: 6

Views: 8356

Answers (3)

Rendolf
Rendolf

Reputation: 96

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

Upvotes: 3

Fast Mani
Fast Mani

Reputation: 181

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

Upvotes: 3

marsze
marsze

Reputation: 17064

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?

Upvotes: 4

Related Questions