js-examples icon indicating copy to clipboard operation
js-examples copied to clipboard

The module example fails due to CORS

Open YagaoDirac opened this issue 3 years ago • 1 comments

I tried modules/basic-modules/ Nothing displayed in the browser. In F12 console, I see Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///E:/js%20examples%20from%20mdn/js-examples-master/modules/basic-modules/main.js. (Reason: CORS request not http). 2 Module source URI is not allowed in this document: “file:///E:/js%20examples%20from%20mdn/js-examples-master/modules/basic-modules/main.js”.

YagaoDirac avatar Oct 19 '21 08:10 YagaoDirac

You need to load your files through a web server, not directly from the file system (e.g http-server). Also make sure that your web server sets the correct mime type for js files.

jesperp avatar Dec 24 '21 19:12 jesperp