Problems loading GLTF on github pages


I’ve just pushed a website that was working perfectly locally to github, but I get an error when I want to host it on github pages.

GLTFLoader.js:154 SyntaxError: Unexpected token v in JSON at position 0
at JSON.parse (<anonymous>)
at GLTFLoader.parse (GLTFLoader.js:281)
at Object.onLoad (GLTFLoader.js:174)
at XMLHttpRequest.<anonymous> (three.module.js:36358)

As far as I understand this is because my GLTF object is not responding with a json. But this means that I won’t be able to host my site on github pages because I can’t host a gltf file? Or is there a possible solution?

This is the response I see in the console from my gltf object.

Hope there is a solution! Thank you in advance

You’re very likely correct. Could you share the code you use to load the model (the GLTFLoader part) ?

(Also, this may help.)

If you’re using Git LFS then you won’t be able to serve a model to github pages. That file content is the hash that LFS uses to download the file on git pull.

1 Like

Thank you! After reading the thread you share, I’ve tried the url with the commit number, and now the error is different.

Mi code after changing the url:

const loader = new GLTFLoader().setPath( ‘’ );
loader.load( ‘uni5.gltf’, function (obj) {

                objectSheep = obj;		
				objectSheep.scene.traverse( ( child ) => {
					if ( child.isMesh ) {
						child.material = materialSheep; 
						child.material.side = THREE.DoubleSide;}				
				} );

                scene.add( objectSheep.scene );

            } );

The console now:

And my code before was:

const loader = new GLTFLoader().setPath( 'models/' );
            loader.load( 'uni5.gltf', function (obj) {

This is the repo:


Opss yes, that’s exactly what I’m using.
I found that as the. only alternative to upload the model.
Don’t know if there is another.


I’ve finally hosted the site in 000webhost and works perfect!

Thank youu

1 Like