jeffreylanters / react-unity-webgl

React Unity WebGL provides a modern solution for embedding Unity WebGL builds in your React Application while providing advanced APIs for two way communication and interaction between Unity and React.
https://react-unity-webgl.dev
Apache License 2.0
1.75k stars 162 forks source link

Uncaught SyntaxError: Unexpected token '<' #529

Closed juankxxD closed 1 year ago

juankxxD commented 1 year ago

Please avoid duplicates

Language and Compiler

Babel and WebPack JavaScript

What environment are you using?

Local Development Server

When does your problem occur?

When the Unity Component mounts

What does your problem relate to?

The problem seems Unity related

React-Unity-WebGL Version

9.4.3

React Version

18.2.0

Unity Version

2022.3.11f1

What happened?

When I create the useUnityContext and place the Unity component, these errors appear:

Uncaught SyntaxError: Unexpected token '<' (at build.framework.js:1:1)

Unable to parse Build/build.framework.js! The file is corrupt, or compression was misconfigured? (check Content-Encoding HTTP Response Header on the web server) build.loader.js:1 Uncaught ReferenceError: unityFramework is not defined

at i.onload (build.loader.js:1:7809) And then, this message appears:

[UnityCache] 'http://localhost:3000/Build/build.data' successfully downloaded and stored in the indexedDB cache

Reproducible test case

image image

Would you be interested in contributing a fix?

jeffreylanters commented 1 year ago

Could you try removing the leading period from the URLs?

juankxxD commented 1 year ago

I already fixed it, the problem was with the extension of my build files, I had to use the 'gunzip' command on each '.gz' file to decompress 'build.framework.js.gz', and it's working now.