Search code examples
xmlamazon-web-servicesweb-serviceshttp-status-code-404aws-amplify

AWS Amplify Console shows weird xml instead of 404


I´ve deployed a vanilla js app via the AWS amplify console and got a subdomain from amplifyapp.com. When I call source files directly, f.e. master.myappid.amplifyapp.com/js/index.js, the content is being shown like it should. Also, when calling the domain without any specific file, it will show the index.html as expected. But, when calling non-existant folders or just a sub-folder, not a specific file in it, it will not throw a 404, but instead show a weird xml response, something like this:

<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>X</RequestId><HostId>X</HostId></Error>

Also, when calling non-existant files, f.e. /abc.html, it will also show this message. How can I setup a rule to make AWS Amplify Console show a 404 when sub-directories with no index.html, non-existant directorys or non-existant files are being called?


Solution

  • So, the solution was way easier than expected. Just add a rewrite rule (In your amplify console at the left sidebar) with a source address of <*>, a target address of /404.html (or any other error page) and a type of "404 (Not found)". Any 404´s will now be redirected to 404.html, which you will have to create and write some informative 404 page for ;)