I am trying to import a module to my index.html file.
Here is the code:
// Index.html:
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title></title>
</head>
<body>
<div></div>
  <script type="module" src="module.js"></script>
  <script type="text/javascript">
    import { addTextToBody } from 'module.js';
    addTextToBody('some text here');
  </script>
</body>
</html>
And the js:
export function addTextToBody(text) {
  const div = document.createElement('div');
  div.textContent = text;
  document.body.appendChild(div);
}
I am getting these errors:
Uncaught SyntaxError: Unexpected token { - Line 18
Access to Script at 'module.js' from origin 'null' has been blocked by CORS policy: Invalid response. Origin 'null' is therefore not allowed access.
How can I fix this?
 
    