Reputation: 26107
I have built my angular app using ng build --prod
and copied the contents of the dist
folder to an S3 bucket. The app works fine if I point my browser to http://abc.xyz.com
. The links inside the app work too if navigating inside the app. Ex: http://abc.xyz.com/information
However, If I copy the URL to a component Ex: http://abc.xyz.com/information
and enter it in the address bar, I get a 404 error. Why is the routing not working, using this way and how do I fix it? I am not sure what web server Amazon uses to serve an angular app.
Upvotes: 1
Views: 1642
Reputation: 1230
Hey take a look at https://angular.io/guide/deployment#routed-apps-must-fallback-to-indexhtml this explains the behavior and solves the problem. The angular app handles the routes defined inside your webapp. If you try to navigate to that path in your filesystem there won't be a file and your server doesn't know where to look.
Upvotes: 1