Distribute i18n application with Angular with new base-href

Discussão em 'Angular' iniciado por Tom, Novembro 12, 2024.

  1. Tom

    Tom Guest

    I created an Angular application using i18n. The issue is that when I build my application with the following command ng build --configuration production --base-href / --localize, the app it always looks for assets in the root folder of the language when trying to run the project. For example: /en-us/main.js, /es-es/main.js.

    However, I configured my server so that depending on the browser's language, it loads a directory without the end user seeing the language directory, for example:

    example.com/app instead of example.com/app/en-us.

    On the server side:

    www.example.com/app > /var/www/langs/en-us/example.com
    www.example.com/app > /var/www/langs/es-es/example.com
    www.example.com/app > /var/www/langs/en-gb/example.com


    However, because Angular compiled pointing to the language directory, it always returns 404 when reading the script.

    How can I make the built application always point to the JS and CSS in the root of the project instead of the language-specific directory?

    Continue reading...

Compartilhe esta Página