wiimote-webhid icon indicating copy to clipboard operation
wiimote-webhid copied to clipboard

Running locally in Chrome

Open alarmatwork opened this issue 3 years ago • 4 comments

Massive Kudos for all the work. I will try to play around with machine learning a bit and use Wiimote as an input.

When you try to run index.html locally directly in browser, then it will raise an error

Access to script at 'file:///Users/xyz/code/wiimote-webhid/index.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, brave, chrome-untrusted, https.
index.js:1 Failed to load resource: net::ERR_FAILED

Is there any workaround for this or I should rather run it through the webserver?

alarmatwork avatar Aug 18 '21 07:08 alarmatwork

Hi Alar! Thank you for checking it out.

The index.html page uses type="module" to load the javascript file so you'll have to use a web server or a static http server.

Machine learning? Are you doing some kind of gesture recognition?

PicchiKevin avatar Aug 18 '21 07:08 PicchiKevin

Thanks will check how to get it working from the local file, seems like a Access-Control-Allow-Origin issue!

Yes, planning to learn TensorFlow a bit and will try to make machine learning to recognise letters written into the air with a Wiimote - just for fun and sake of learning since I have a wiimote laying in the drawer anyway. There is still a long way to go, but I will open source the code once I will get there.

alarmatwork avatar Aug 18 '21 07:08 alarmatwork

You can close the issue. Found the workaround. Instead of accessing files through file:// I am running local server just: python -m SimpleHTTPServer in the root directory of the project and then accessing files via: http://localhost:8000

alarmatwork avatar Aug 18 '21 08:08 alarmatwork

For local dev purposes, adding http-server as dev dependency and invoking it as npm start, i.e. as start script in the package.json, could improve the developer experience.

Ryuno-Ki avatar Aug 20 '21 15:08 Ryuno-Ki