【发布时间】:2021-01-08 05:34:49
【问题描述】:
我的 Angular 10 应用程序的 NGINX 配置有问题。 似乎 nginx 配置中的以下块与配置的所有其他位置混淆。
location / {
alias /var/www/html/myapp/;
try_files $uri $uri/ /index.html =404;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
}
根路径上的这个webapp打开一次后,不先清除浏览器缓存,就无法访问其他应用了。
其他应用的配置方式类似:
location /app2/ {
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
alias /var/www/html/app2/;
try_files $uri /$uri/ index.html =404;
}
当我打开 app1 后打开 http://host/app2/ 时,角度路由器似乎想要处理 app2 路由,这导致根应用程序中出现 404。
我该怎么办?您知道防止此问题的设置吗? 这是 NGINX 的问题吗?
提前谢谢你!
问候
斯蒂芬
【问题讨论】:
标签: angular nginx configuration routes router