HTTP request blocked by CORS policy

I’m trying to load a 3D GLTF model from a python server I’m locally hosting, something like http://localhost:8000/navigate/to/GLTF.gltf. I’m using GLTFLoader with this code:

var loader = new THREE.GLTFLoader();
function (gltf){

After running this it comes up with an error in a chrome browser opened with “start chrome --allow-file-access-from-files”:
“Access to XMLHttpRequest at ‘http://localhost:8000/navigate/to/GLTF.gltf’ from origin ‘file://’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.”
This only doesn’t work with localhosting, it works when I simply call the loader from my files normally, but I need to be able to pull a model from a local host. any suggestions?

EDIT: Formatting

You have to move the entire app (e.g. the index HTML file) on the same web server. It does not work if you open the application from file or from a different host. If you have to use for some reasons a different host, configure your web server so it correctly applies CORS header to the HTTP response.

BTW: It’s best to completely avoid the file protocol. More information about that topic in this guide:

Moving everything to the web server worked great, thank you!