Deployed to S3 - refresh a page gives Access denied

I deployed a simple Ember app to Amazon S3 just to get some experience on how it works. The app is available here. The back-end is a Rails 5 API hosted at Heroku.

The only available url is to get articles resource.

It works only when I click on Articles link. If I try to refresh the same URL, I get:

Code: AccessDenied
Message: Access Denied
RequestId: C1ADD449381452D4
HostId: f6GAIzNGnkrAjJKVLJQfDt2iDo6/ERNUcat/pG9aeb1/Jqg7x0FEIZeYzNJszFyrbWSdy3h6dxk=

Why so ?

I tried to apply redirections rules as described in ember-cli-deploy-s3-index bu putting the XML settings as in the below screenshot, but it is not valid:

So what is the right way to go:

  • either set locationType to hash in environment.js settings (or to keep the defaultauto? )
  • any other solution ?

Thank you.

I figured out myself.

You should not take http:// part of the AWS end point url for HotName tag, just like that:

<RoutingRules>
    <RoutingRule>
        <Condition>
            <HttpErrorCodeReturnedEquals>403</HttpErrorCodeReturnedEquals>
        </Condition>
        <Redirect>
            <HostName>simple-api-client.s3-website.eu-central-1.amazonaws.com</HostName>
            <ReplaceKeyPrefixWith>#/</ReplaceKeyPrefixWith>
        </Redirect>
    </RoutingRule>
</RoutingRules>

I also kept locationType set to its default value: auto. Hope this helps.

2 Likes