Search code examples
javascriptangular5firebase-hostingunity-webgl

Host Unity WebGl on Angular app on Firebase hosting


I have an angular app where I read Unity WebGl in a iframe. I use the url /assets/webgl/index.html to launch the webgl.

All works in dev, but when I deploy on Firebase, I got this error :

UnityLoader.js:1 Invoking error handler due to Uncaught SyntaxError: Unexpected token < blob:https://MYPROJECT.firebaseapp.com/1002467b-4c14-4974-af91-23aca8b2f4e6:1 Uncaught SyntaxError: Unexpected token <

That's probably firebase rewrite rules because it loads a blob:[my project url]. So I think it is replacing my assets url by the default 'angular' url but I can't find anything related to this.

I've already seen those links but they're old and useless for me :

Anyone faced this issue before ?

I use chrome


Solution

  • By the may, my problem was in the firebase.json :

    There was a rewrite rule which makes assets not accessible...

    "rewrites": [
       {
          "source": "**",
          "destination": "/index.html"
       }
    ]
    

    I had to add a rule like this :

    {
      "source": "**/assets/webgl/**",
      "destination": "/assets/webgl/index.html**"
    }