2
votes

I am building an application with the help of Angular6 and having problem in routing. All the routes are working when I click on a particular tab but whenever I refresh the current page, it is throwing 404 error. I tried Hashtag location strategy but getting # in URl. Is there any other way to implement without hash strategy. Currently application is hosted in AWS.

2

2 Answers

2
votes

one work around is adding index.html in error document section but it isn't recommended.

enter image description here

check other solutions here.

0
votes

Take a look at the Deployment section in the docs if you are using EC2. The webserver you are using must handle those requests:

If the app uses the Angular router, you must configure the server to return the application's host page (index.html) when asked for a file that it does not have. A routed application should support "deep links". A deep link is a URL that specifies a path to a component inside the app. For example, http://someurl/heroes/42 is a deep link to the hero detail page that displays the hero with id: 42.

Are you using any webserver such as Apache or Nginx?