Andrew's Digital Garden

Hosting a SPA on S3

[[S3]] is made to host static websites. It maps the file structure to your domain. e.g. s3-bucket/about/index.html an be loaded at example.com/about. Since [[SPAs]] use client side routing, there's only one index.html. The routes are defined in a single app, and that's it.

A hack(?) to make these URLs work is to make the index document and error document the same index.html. Although going to example.com/about will cause an HTTP error, it will still route you to the main entry point where client side routing can kick in again.

As a side note, you can point URLs to different S3 routes and break the 1:1 relationship through tools like CloudFront.

[[20211122033810-aws-s3-basics]]

[[architecture]] [[aws]] [[deployment]]

Hosting a SPA on S3