☑ CORS local files - XMLHttpRequest cannot load

Hi! I want make local version game, without server. I download resourse at dekstop and open index.html in chrome for test. Console show me:
playcanvas-stable.min.js:12983 XMLHttpRequest cannot load file:///C:/Users/User/Desktop/Sleg/config.json. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
What i can do?

Opening file directly in browser - is very strict and limiting by browsers, to avoid serious security issues.
So you will need a local web server, to work with any web related projects, including PlayCanvas.

XAMPP or NGINX (I prefer nginx) - are easy to install and use.

1 Like

i think, team Playcanvas need think about it problem. i can use server when i bulid decstop game for windows or another platform? I can add server in proect?

That is no PlayCanvas thing :slight_smile:
But general Web thing - you need web server, to create web applications. That is general practice and requirement for making anything related to things that are blocked by browsers due to security reasons. It is down to Google, Microsoft and other companies doing it, to protect users from being able to be hacked or have privacy endangered by allowing things such as textures loading to GL from local file, without explicitly allowing CORS.

The fact that browser is capable of doing file:// protocol in first place, is not web thing.

I just use this nice simple command-line server to quickly run a local server inside my local downloaded playcanvas project

https://www.npmjs.com/package/http-server

1 Like