我有一个在ngInix本地服务器上托管的angular i18n应用程序。除了加载字体外,应用程序按预期工作。
Angular总是查看NgInix服务器的根文件夹来查找字体文件,而不是查看locale文件夹中的asset文件夹。下面是我的文件夹结构Folder structure
这是我的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 *;
}
# ...
}
字符串
来自控制台的错误(https://i.stack.imgur.com/CTuAu.jpg)
我尝试在ngInix.conf文件中重写字体请求,但没有成功。感谢任何帮助。
1条答案
按热度按时间mnemlml81#
你应该相应地更新你的angular.json,告诉angular必须使用特定的字体,有一个类似的问题已经解决了:How to use local font family in Angular 8?