3 ms·
A problem my team hits with micro projects with this is: virtual routes like `/login` doesn’t map to a file. What can be done about that?
by cordite 7y ago
A problem my team hits with micro projects with this is: virtual routes like `/login` doesn’t map to a file.
What can be done about that?
- maest 7y ago/login makes me think your website isn't really static. Regardless, you can use extensionless links with your static website if you rename the file from login.html to login, then change the file metadata to Content-Type: 'text/html'
- procinct 7y agoWhy would it not be static? It could be a static site making a request to an API to log in?
- tfolbrecht 7y agoLike a SPA? You use a something like react router and set the S3 error page to your index. I've deployed many SPAs to AWS S3/ Cloudfront. You have to handle the 404 page in app Here's a SO post https://stackoverflow.com/questions/51218979/react-router-doesnt-work-in-aws-s3-bucket https://stackoverflow.com/questions/51218979/react-router-do...
- danielstocks 7y agoMost servers will route /login/index.html to /login
- kesor 7y agoYou can also use Lambda@Edge with CloudFront to do any kind of logic required, like redirects, rewrites, etc...
- bett3513 7y agoYou can add an error behaviour in cloudfront that defaults the 404 behaviours to the index page. If you also add the index and error of the S3 config to the same index page it all works perfectly. We have multiple React sites deployed this way to S3/Cloudfront with react-router and experience no issues.