Re:Deploying front-end websites to S3 with CloudFront
by irjoe on Saturday February 15, 2020 @04:42PM
(#22338193)
I've found a fairly workable solution is to have an origin for the API in CloudFront and a behaviour to route /api/* to that origin. Saves any CORS headaches. Obviously this won't work in all cases.
[ Parent
| on HN ]
Re:Deploying front-end websites to S3 with CloudFront
by saidmasoud on Saturday February 15, 2020 @11:34PM
(#22339792)
Just remember, the route prefix you use to define the CloudFront behavior will also be added to the request sent to the origin server. So in this case, all routes defined by the API must be prefixed with `/api/`. This makes it hard to refactor existing APIs with many routes and dependencies, but works great in a greenfield scenario.
(Of course, you can rewrite the URL on the fly via Lambda@Edge but that's a PITA to maintain)
Re:Deploying front-end websites to S3 with CloudFront
by hkchad on Saturday February 15, 2020 @08:39PM
(#22339298)
Here's a writeup on the details. https://medium.com/@chad.h.dalton/how-we-reduced-our-api-cal...