- Newest
- Most votes
- Most comments
This is quite a mystery. Missing a lot of details, here are my first thoughts on this:
Potential Causes:
Index Document Setting: Ensure that the index document setting in your S3 bucket is correctly configured to point to your main index file (e.g., index.html). This setting controls the initial page that is loaded when visitors access your site.
Browser Caching: Sometimes browsers cache older versions of the site. Try clearing your browser's cache, or use an incognito window, and then accessing the website again.
React Router Configuration: Since you're using React, you might be using a client-side router (e.g., react-router-dom). Ensure that it is configured correctly to handle your routes and that it is not causing the URL to change unexpectedly.
Possible Solutions:
Review S3 Configuration: Double-check your S3 bucket configuration, ensuring that the bucket hosting and endpoint settings are correctly configured.
Review CloudFront Settings: Since you are using AWS CloudFront for distribution, check your settings to ensure that you've set the default root object to your main HTML file (usually index.html).
Update React Router Configuration: Review your React Router configuration to ensure that the routes are set up correctly. If necessary, update the base URL in your router configuration to match the URL of your S3 bucket.
URL Rewriting: You may need to configure URL rewriting to ensure that all routes point to your index.html file. You can do this using routing rules in your S3 bucket settings.
Invalidate CloudFront Cache: If you're using CloudFront, perform a cache invalidation to remove the old version of your site from CloudFront's cache. I know you mentioned you did this already but just adding it for good measure.
Check Console Errors: Open your browser’s console to check for any errors that might provide clues about the issue.
I hope this helps you track it down, and please update the question once you do to close the loop, I am genuinely curious what is causing this behavior for you.
Relevant content
- asked 4 years ago
- asked 2 years ago
- asked 10 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a month ago
Hi could you please clarify how this static website is hosted? S3's built-in website hosting doesn't support https so are you using CloudFront?
@skinsman, yes I'm using cloudfront, and I did invalidations on /* with cloudfront after updating my s3 bucket to clear the cache. The only changes I made were what was inside my s3 bucket, and invalidating the cloudfront cache, so I'm really confused how the url managed to change.