Jay
Jay

Reputation: 107

SOLVED___Using AWS S3 to Webhost is giving no key error

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>

Upvotes: 0

Views: 2688

Answers (2)

Jay
Jay

Reputation: 107

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.

Upvotes: 6

E.J. Brennan
E.J. Brennan

Reputation: 46869

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.

Upvotes: -1

Related Questions