【问题标题】:On Reload Angular7 application getting 404 after deployment在部署后重新加载 Angular7 应用程序得到 404
【发布时间】:2022-01-31 19:45:24
【问题描述】:

从 URL 中删除 # 在使用“{provide: LocationStrategy, useClass: HashLocationStrategy}”之前 这在 appModule 文件中删除后得到 404 和

https://example.com/dashboard//home 在日志中我看到 NGINX 添加了一个额外的“/”

NGINX 更改后

 location / {
    alias /usr/share/nginx/html/;
         try_files $uri $uri/ /index.html;
          try_files $uri $uri/ = 404;
            try_files $uri $uri/ /index.html =404;
  }

尝试了以下 2 个解决方案

Angular 2 Hosted on IIS: HTTP Error 404

Angular deployment - 404 on page Refresh

【问题讨论】:

  • 试试这个:root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; }
  • 您尝试了哪种解决方案?请说明您到底尝试了什么。另外:angular.io/guide/…
  • @penleychan 尝试更改 NGINX 配置,但不确定在部署 y 后给出 404 ,之前在 URL 中使用 # ,现在在开始获取此内容后将其删除。
  • @penleychan angular.io/guide/… 也试过这个

标签: javascript angular nginx


【解决方案1】:
location / {
    include /etc/nginx/mime.types;
    try_files $uri /index.html =404;
}

将此添加到 NGINX 并为我工作

谢谢:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-29
    • 1970-01-01
    • 2020-10-16
    • 1970-01-01
    • 2014-01-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多