With this bucket policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::mypage.com/*"
}
]
}
I am deploying a website that is build by reactJS v16+ (react-router-dom v5), and when I open the url, it works perfectly, e.g. from mypage.com, the that goes to /list works fine. Url is loaded as mypage.com/list and the page content is displayed.
However on any child page that is not homepage, for example mypage.com/list, once I refresh the page with browser, it returns S3's 404:
404 Not Found
Code: NoSuchKey
Message: The specified key does not exist.
Key: list
I don't even know how to debug this... any idea?
index.html
(or your root html file) as error document(onError Pages
creating a custom error message and setting response code to 200). This is one of the easiest hack to get this working. – Beemlist
in the root of your bucket, or when users go tomypage.com/list
are you wanting them to actually see theindex.html
file in the/list
directory? – Fireboxindex.html
as theindex
document? What happens if you go tomypage.com/list/
(with the final slash) but without the Error Page hack? – Firebox