0

I have an angular i18n application hosted on ngInix local server. The application is working as expected except loading the fonts.

Angular is always looking at the root folder of NgInix server to find the font files instead of looking at the asset folder in the locale folder. Here is my folder structure Folder structure

Here is my nginix.conf

http {
    include       mime.types;
    default_type  application/octet-stream;
   
    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
     map $http_accept_language $accept_language {
        ~*^en-US en-US;
        ~*^en-CA en-CA;
        ~*^en en;
    }

server {
    listen 80;
    server_name localhost;
    root html;

    # Fallback to default language if no preference defined by browser
    if ($accept_language ~ "^$") {
        set $accept_language "en";
    }

    # Redirect "/" to Angular application in the preferred language of the browser
    rewrite ^/$ /$accept_language permanent;

    # Everything under the Angular application is always redirected to Angular in the
    # correct language
    location ~ ^/(en-CA|en-US|en) {
        try_files $uri /$1/index.html?$args;
    }
    
    location ~* \.(eot|ttf|woff)$ {
    add_header Access-Control-Allow-Origin *;
    }
    # ...
}

Error from console (https://i.stack.imgur.com/CTuAu.jpg)

I tried to rewrite the font request in the ngInix.conf file, but not worked. Any help appreciated.

1 Answers1

0

You should update your angular.json accordingly to tell angular that a specific font has to be used, there is a similar question which is already solved this: How to use local font family in Angular 8?

Oscar
  • 1
  • 1
  • I really don't think its related to how the fonts are being used in the application as it working fine when I am running it without using ngInix local server. The issues is only when I run the application using ngInix server – Libin Jose Jul 12 '23 at 19:34