Search code examples
angularfirebasewebfirebase-hosting

How to serve effective AOT language Angular app in Firebase hosting?


I have an angular 4 app hosted by Firebase hosting service with a custom domain (ex: www.something.com that redirects to firebase url). I used i18n internationalization and my question is: Which is the best way to serve the correct compiled app depending the user nation? In this moment there's only the standard --aot en online and I'd like to serve the --aot it version if someone comes from Italy for example.

Thanks


Solution

  • I also ran into the same problem. I accomplished it by making changes to the firebase.json Hosting attribute

    {
      "hosting": {
        "public": "dist",
        "ignore": [
          "firebase.json",
          "**/.*",
          "**/node_modules/**"
        ],
        "redirects": [
          {
            "source" : "/",
            "destination" : "/en",
            "type" : 301
          }
        ],
        "rewrites": [
          {
            "source": "/en/**",
            "destination": "/en/index.html"
          },
          {
            "source": "/es/**",
            "destination": "/es/index.html"
          },
          {
            "source": "/fr/**",
            "destination": "/fr/index.html"
          }
        ]
      }
    }
    

    Hope this helps you!