Search code examples
node.jsamazon-web-servicesserver-side-renderingaws-amplifyisomorphic-javascript

403 Access Error returned from Browser possibly caused by AWS


I have my serverless web app hosted on AWS amplify. I am getting Access Denied error XML if I try refreshing the page. When I look into the Console, it shows no output. The code works fine on localhost, but will cause 403 error on live.

I have found a question that is very similar, except I did not use CloudFront.

enter image description here

How can I find a potential cause of this problem?

enter image description here

I have tried using Digital Ocean as my web hosting service instead of AWS. The same error happens.


Solution

  • I solved this by moving from AWS to Nginx for hosting.

    And added this to etc/nginx/sites_available/default

    location / {
                    # First attempt to serve request as file, then
                    # as directory, then fall back to displaying a 404.
                    #try_files $uri $uri/ =404;
                    try_files $uri /index.html;
            }
    

    The reason why this is happening is because my app was a single paged app. Refreshing causes the browser to request the server, and the server does not handle requests.