0

I am trying to host a site with muliple paths on a S3 Bucket. Is this an available option ?

These two work on my local machine.

localhost:3000

localhost:3000/policy

Trying to host this on S3 is giving me no key error

example.com <-- Works

example.com/policy <-- does not work with no key error

Exact Error

404 Not Found Code: NoSuchKey

Message: The specified key does not exist.

Key: policy

I should mention

I am using React-Router-Dom switch on the App that is working on localhost

<Switch>
    <Route path="/policy"><PolicyComponent><Route>
    <Route path="/"><HomePageComponent><Route>
<Switch>
Jay
  • 117
  • 1
  • 9
  • By "no key error", can you be more specific? Is it an HTTP 404 response with NoSuchKey? – jarmod Dec 26 '19 at 19:18
  • @jarmod edit done – Jay Dec 26 '19 at 19:22
  • Is this a completely static website? Is there a document named `policy` in the root of the S3 bucket? Also, see https://aws.amazon.com/premiumsupport/knowledge-center/404-error-nosuchkey-s3/ – jarmod Dec 26 '19 at 19:26
  • it's not a static website, but it is a complete client side only website – Jay Dec 26 '19 at 20:05

2 Answers2

6

react router doesn't work in aws s3 bucket

Very Simple Fix,

All I needed to do was indicate any errors to index.html

I did not provide index.html on the set up.

Jay
  • 117
  • 1
  • 9
0

If the html file name is 'policy.html', they you need to reference it as such, if you want the url to just be example.com/policy, you would create a folder called 'policy' under the root and put the contents in a file called index.html in that bucket.

E.J. Brennan
  • 45,870
  • 7
  • 88
  • 116
  • Can S3 handle the incoming of random paths. Because I have localhost:3000/randomString working.....wondering if I need to switch to dynamic hosting, even though my app is technically server-less – Jay Dec 26 '19 at 19:43