Configuring CORS is probably the biggest pain about this approach and is necessary if you want to send data to and from an API. This guide should probably mention it or link another guide.
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.
Deploying front-end websites to S3 with CloudFront
11–20 of 33 posts
Re: Deploying front-end websites to S3 with CloudFront
#12Earlier quoted context omitted.
Just change the Access-Control-Allow-Origin header. Am I missing something?
Access-Control-Allow-Credentials too and it needs to be configured on both the client and the server.
Re: Deploying front-end websites to S3 with CloudFront
#13Re: Deploying front-end websites to S3 with CloudFront
#14A 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?
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
#15If it's just a personal website, you might find it easier to use GitHub Pages (or GitLab's equivalent) and Cloudflare. Both are free for any reasonable personal website usage. If you don't want to run a build of your static site generator on your computer and upload the result to GitHub every time you make a change, you can just use Jekyll and GitHub will build it for you. I think GitLab supports other static site ge…
CF is not necessary anymore for SSL since GH can issue LetsEncrypt certificates automatically. https://help.github.com/en/github/working-with-github-pages/...
Re: Deploying front-end websites to S3 with CloudFront
#16A 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?
Here's a SO post https://stackoverflow.com/questions/51218979/react-router-do...
Re: Deploying front-end websites to S3 with CloudFront
#17A 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
#18Re: Deploying front-end websites to S3 with CloudFront
#19A 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
#20Configuring CORS is probably the biggest pain about this approach and is necessary if you want to send data to and from an API. This guide should probably mention it or link another guide.