File not found when importing glb

First off I want to clarify that the glb file is there. I know because because I’ve tried putting a text file in the same folder instead, and that was found. I’ve double checked the extension and also tried the gltf format. It has been exported from Blender 2.82.
This is my js code:

  import * as THREE from './three/build/three.module.js';

   var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
  camera.position.set( 500, 800, 1300 );
	camera.lookAt( 0, 0, 0 );

  var scene = new THREE.Scene();
  scene.background = new THREE.Color( 0xf0f0f0 );


  var renderer = new THREE.WebGLRenderer( { antialias: true } );
	renderer.setPixelRatio( window.devicePixelRatio );
	renderer.setSize( window.innerWidth, window.innerHeight );
	document.body.appendChild( renderer.domElement );

import { GLTFLoader } from './three/examples/jsm/loaders/GLTFLoader.js';

var loader = new GLTFLoader();

loader.load( 'cube.glb', function ( gltf ) {
  var model = gltf.scene;
  scene.add( model );
} );

renderer.render( scene, camera );

Does anyone know what could be wrong? Any help is greatly appreciated.

Loading files just by defining their name (e.g. ‘cube.glb’) does work if the file is in the same directory like the executed code. Can you please share a GitHub repository that demonstrates this error? Or maybe some sort of live example?

I’m running on local server using .net core. I don’t know how easy this is at the moment. Btw, I tried with the .obj file loader and it only executes the error function. Same as with my code above.

Edit: I found the issue. IIS didn’t serve the file. This page gave me the solution: iis-refuses-to-serve-static-gltf-files I still can’t see my cube (no errors anymore), but I managed to load, and see, another gltf file I downloaded, so I know it works now after appending some C# code. This was much more complicated than I initially thought.

IIS requires you to set allowed mime types that can be served.

Yes. I figured it out. Didn’t cross my mind before I stumbled upon the article I linked in my previous post.