Reputation: 1222
I have deployed my Angular2 application on Amazon S3 successfully. It works fine. All routing works fine when I navigate using routeLinks/code.
But when I refresh the page, or jump to particular route, I get 404 error as follows.
The thing is, we know we have dynamic routes in Angular2. There is no physical directory with that path/route name in final code base deployed/stored in S3 bucket. But, I think S3 considers it as physical object stored in S3 bucket, which it fails to fetch.
How to resolve this issue?
Upvotes: 17
Views: 10035
Reputation: 69
If you are using AWS cli to copy dist folder to your bucket then it copies the project folder to your bucket which contains your files including index.html
.
Try uploading contents of dist/< your_project>/
directly to your bucket.
It worked for me.
I think S3 is expecting an index.html
file at its root level
Upvotes: 0