+ 2

Access to Script at ' from origin 'null' has been blocked by CORS policy

I was doing the modules lesson today in JavaScript course, so I wanted to play around with modules a little to understand them better, this error appears however and my modules don't work: Access to script at '....my folder location.....' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https. How do I fix that?

27th Nov 2020, 6:05 PM
Karak10
Karak10 - avatar
2 Answers
+ 5
For security reasons, scripts that run on a browser may not make requests to the file system. You can start a Node server on your local machine. If you load the page with http or https protocol, EcmaScript modules will work. If you prefer to use the file:// protocol, you should consider transpiling your EcmaScript code with Babel to something compatible with most browsers.
27th Nov 2020, 6:36 PM
Ore
Ore - avatar