14
votes

At the moment I'm hosting a bundled Angular-2 App in an AWS S3 bucket, so it only contains .html and .js files.

The absolute path http://example.com/ does work but if I switch to any links, such as http://example.com/testsite it returns 404 error as below:

404 Not Found
Code: NoSuchKey
Message: The specified key does not exist.
Key: voucher
RequestId: 7A08F32C18D3C6D3
HostId: 6jTd5D5QDU+AP4vo+uRcHHVT5WeRAKjoPeqVb39xoKZZSvWWz/9TsNp41TbuKXmtpYbLZJiyqwE=

I already tried another bucket policy and I set every file to public, but it won't work for me.
Anyone has a solution? Please help.

3

3 Answers

19
votes

In my case, I had to specify index.html in both Index document and Error document on S3 Static website hosting properties.

15
votes

Your bucket policy Resource property needs to contain, note the /*:

"Resource":["arn:aws:s3:::bucketname/*"]

You also need to set the error document to be your index.html

0
votes

Specifiying index.html in the error page solved the issue for me too.