SyntaxError: Unexpected token < in JSON at position 0

Hi,
I’am trying to load GLTF model of parrot. I downloaded the model and I imported a GLTFLoader. When I try to create a GLTFLoader it says:
image

On my server I’am using parcel.js
It’s interesting that on the codesandbox it is working properly…

Maybe it’s something wrong with parcel?
Do you know what am I doing wrong?

Thanks

1 Like

This error usually appears if the HTTP request for the glTF asset returns a HTML site. I suggest you open the asset URL directly in your browser and check the content.

Hi thanks for help!
But I’am big noob :smile: did you mean it like that?


Bcs I have still same error. Even in my network there isn’t any fail:

Can you please post a screenshot of the HTTP response data of Parrot.glb?

Of course


Yep, that’s the problem. Your web server does not serve a glb but HTML content.

1 Like

I understand the problem but how can i fix it ? Is changing the web server the only way or is there other things that i can do ?

I would ask a question to the folks who develop the respective web server.

1 Like

Sorry for the bump but I am a having exactly the same error. After some researching, I am still stuck. @Rafael_Leme, did you solve this problem?

Cheers!

hello,I have the same problem when I am loading a fontLoader.Did you solve it?

In order to debug this, check the network tab of the developer console.

Here’s a screenshot of how it looks like in the first of the examples:

If you’re loading a GLTF model, then your response should like like the response in my screenshot.
If you’re loading a font, it should obviously not look like my screenshot since it’s a different file type than GLB :smiley:

If the response looks like an HTML page, that means you need to configure your server properly, and if you want help you should provide information on how you are serving your files as there are many possible reasons for it not working.

Thanks! My page really is a html page.I use parcel-bundler.This is my code,file path,package.json,developer console response,and error message.
The code in main.js.



fileTree



I use npm run start to run my web.
Will these help solve the problem? If not, what information is needed?

i solved the problem moving the file .gltf to the public repo

2 Likes

For me, this was a web server configuration issue. I fixed it by adding gltf to the list of extensions to ignore in server rewrites and redirects.

I was trying to load a gltf model and I was constantly getting this error.

Ekran Resmi 2023-12-31 10.50.09

Then I took the draco decoder file to the public folder

// dracoLoader.setDecoderPath('three/examples/jsm/libs/draco') ❌
dracoLoader.setDecoderPath('/draco/') ✅