OiO.lk Blog javascript I get this error in google chrome console when I try to run the html file
javascript

I get this error in google chrome console when I try to run the html file


Access to XMLHttpRequest at ‘file:///home/h/Documents/personal/self%20study/react/scrimba/Scrim-s0hsaqhfmk/index.js’ from origin ‘null’ has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: chrome, chrome-extension, chrome-untrusted, data, http, https, isolated-app.

index.js

ReactDOM.render(<h1>Hello, everyone!</h1>, document.getElementById("root"));

index.html

<html>
  <head>
    <link rel="stylesheet" href="index.css" />
    <script
      crossorigin
      src="https://unpkg.com/react@17/umd/react.development.js"
    ></script>
    <script
      crossorigin
      src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"
    ></script>
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
  </head>
  <body>
    <div id="root"></div>
    <script src="index.js" type="text/babel"></script>
  </body>
</html>

The browser should show the text inside H1 tag, instead it shows blank page



You need to sign in to view this answers

Exit mobile version