News for hackers. Stuff that matters.
Re:Deploying front-end websites to S3 with CloudFront by cordite on Saturday February 15, 2020 @05:01PM (#22338311)
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?
Re:Deploying front-end websites to S3 with CloudFront by tfolbrecht on Saturday February 15, 2020 @05:19PM (#22338416)
Like 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-do...

Re:Deploying front-end websites to S3 with CloudFront by maest on Saturday February 15, 2020 @05:06PM (#22338337)
/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'

Re:Deploying front-end websites to S3 with CloudFront by procinct on Sunday February 16, 2020 @01:44AM (#22340200)
Why would it not be static? It could be a static site making a request to an API to log in?
Re:Deploying front-end websites to S3 with CloudFront by bett3513 on Sunday February 16, 2020 @02:37AM (#22340406)
You 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.

Re:Deploying front-end websites to S3 with CloudFront by kesor on Saturday February 15, 2020 @05:40PM (#22338528)
You can also use Lambda@Edge with CloudFront to do any kind of logic required, like redirects, rewrites, etc...
Re:Deploying front-end websites to S3 with CloudFront by danielstocks on Saturday February 15, 2020 @05:23PM (#22338436)
Most servers will route /login/index.html to /login