Error: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https

If you are facing this error it’s because your page is trying to load a local file using file:// or C:/ (you can see it in the URL on your browser). It happened to me one time, that’s because I created a HTML page and simply double-clicked on it to open it on the browser, my page was using a JSON file from the same folder, and when I checked the console this error was there:

Failed to load file:///C:/project/myProject/data.json: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

Turned out I needed a webserver for this. The solution was to install one on my computer (WampServer or Lamp will do fine) and host my page on it, this fixed the problem for me.

Leave a Reply

Your email address will not be published. Required fields are marked *

Obs: Use the tag <pre lang="LANGUAGE"> to include code blocks to your comment.
Example: <pre lang="javascript"> console.log('Test'); </pre>