Key AWS S3 and CloudFront Edge Cases for Static Site Subdirectory Hosting
A developer deploying a static documentation site on AWS S3 and CloudFront encountered several non-obvious routing and configuration issues. Browser caching of 301 redirects and HSTS policies caused stale behavior in normal sessions even after infrastructure changes had propagated. CloudFront's Default Root Object only resolves index files at the distribution root, not in subdirectories, requiring explicit URL rewriting via a CloudFront Function on the Viewer Request event. Missing trailing slashes in subdirectory URLs caused browsers to misresolve relative asset paths, breaking CSS and JavaScript loading. A concise CloudFront Function that redirects slash-less directory requests and rewrites directory URIs to index.html was found to resolve most of these routing problems.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in