0

Removed # from the URL before using "{provide: LocationStrategy, useClass: HashLocationStrategy}" this in appModule file After Removing this getting 404 and

https://example.com/dashboard//home in logs i saw one extra '/' is getting added from NGINX

After NGINX Changes

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

tried these below 2 solution

Angular 2 Hosted on IIS: HTTP Error 404

Angular deployment - 404 on page Refresh

  • Try this: `root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; }` – Ivan Shatsky Jan 30 '22 at 18:53
  • Which solution did you try? Please state what exactly you tried. Also: https://angular.io/guide/deployment#routed-apps-must-fallback-to-indexhtml – penleychan Jan 30 '22 at 18:54
  • @penleychan tried changing the NGINX config , but not sure after deploying y its giving 404 , before was using # in URL and now removed after that started getting this. – Sakshi Gupta Jan 30 '22 at 18:58
  • @penleychan https://angular.io/guide/deployment#routed-apps-must-fallback-to-indexhtml tried this as well – Sakshi Gupta Jan 30 '22 at 19:05

1 Answers1

0
location / {
    include /etc/nginx/mime.types;
    try_files $uri /index.html =404;
}

added this to NGINX and worked for me

Thanks :)