Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

What is "cross-origin request" error? How do I NOT get it?

The answer about <divs> isn't my solution - In the initial React Scoreboard app, my window (only) shows Loading ...
the React Dev Tool says "babel-browser.min.js:4 XMLHttpRequest cannot load file:///Users/patrick/Desktop/ReactBasicsProject/app.jsx. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https."

4 Answers

Hi Cross-Origin requests is a HTTP Request that is sent from your http://localhost for example to another server - www.example.com and if the server from www.example.com is not set for external access it fails with that error.

A bit more about CORS: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS.

But to help you please post your code from app.jsx to see whats going on. Or maybe you fork your Workspace.

```function Application(props) { return ( <div className="scoreboard"> <div className="header"> <h1>{props.title}</h1> </div>

  <div className="players">
    <div className="player">
      <div className="player-name">
        Jim Hoskins
      </div>
      <div className="player-score">
        <div className="counter">
          <button className="counter-action decrement"> - </button>
          <div className="counter-score">31</div>
          <button className="counter-action increment"> + </button>
        </div>
      </div>
    </div>
    <div className="player">
      <div className="player-name">
        Ella Fitzgerald
      </div>
      <div className="player-score">
        <div className="counter">
          <button className="counter-action decrement"> - </button>
          <div className="counter-score">99</div>
          <button className="counter-action increment"> + </button>
        </div>
      </div>
    </div>
  </div>

</div>

); }

ReactDOM.render(<Application title="My Scoreboard"/>, document.getElementById('container'));```

Do you want the index.html as well? ```<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Scoreboard</title> <link rel="stylesheet" href="./app.css" /> </head>

<body> <div id="container">Loading...</div>

<script src="./vendor/react.js"></script>
<script src="./vendor/react-dom.js"></script>
<script src="./vendor/babel-browser.min.js"></script>
<script type="text/babel" src="./app.jsx"></script>

</body> </html>```

Nejc, Thank you! I didn't run any update or webpack or any other "bundling" to assure that this code is up to date. Did I miss any direction to do so? I am assuming the error would inform me if this is the source of the error.

Did you download the Project data to your computer? Or are you using the Workspace?

When downloading to your computer it's good to run: "npm install" in the project root.

I downloaded the Project File, opened it in Atom , then deleted all the app.jsx code - so that I could follow along. When told to check, I pulled the index.html into my browser and ... it just says Loading forever.

I just ran npm install, but ... there's no package.json file. So I ran npm init, but that produces an empty package.json.

THANK YOU again for trying to help. Any further suggestions? (Do you need to see any other code snippets?)