Notification texts go here Contact Us Buy Now!

AWS not allowing me to access subpages of my static website

Encountering difficulties accessing certain pages of your static website hosted on AWS may be linked to your site's routing mechanism.

Typically, if requests aren't being routed through your index page, a HTTP 404 error is triggered. While utilizing CloudFront, this error might be masked, leading to the appearance of a 403 error.

This issue arises in scenarios where your website directly handles URL paths like /example by searching for an 'example' file within the S3 bucket. Naturally, this file doesn't exist, resulting in an error.

To resolve this, consider implementing an error handling mechanism that redirects such requests to your index page, where a proper routing mechanism can be applied. Within your S3 static website hosting settings, configure the Error Document to index.html.

However, if you want to bypass the hassle of advanced routing mechanisms using S3 setup, Lambda functions, or presenting an error page, you can modify your next.config.js file by adding trailingSlash: true. This modification enables direct loading of subpages without the need for such complexities.

const nextConfig = {
    reactStrictMode: true,
    poweredByHeader: false,
    output: "export",
    images: {
        unoptimized: true,
    },
    trailingSlash: true, // for s3 routing
};

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.