Live data from Hacker News

Deploying front-end websites to S3 with CloudFront

ilhicas.com

1–10 of 33 posts

Re: Deploying front-end websites to S3 with CloudFront

#3
If 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 generators as well. This technique is how https://www.snazz.xyz works.

Re: Deploying front-end websites to S3 with CloudFront

#4
post #3

If 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…

Yes, https://netlify.com is great for this too and supports most static site generators.

Re: Deploying front-end websites to S3 with CloudFront

#6

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.

Re: Deploying front-end websites to S3 with CloudFront

#7

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.

> Configuring CORS is probably the biggest pain about this approach and is necessary if you want to send data to and from an API.

CORS is only needed for the API, not the website, and only if you don't control the API or don't make it so the API can be served (from the client's perspective) from the same origin, perhaps because it's fronted by the same Cloudfront distribution.

Re: Deploying front-end websites to S3 with CloudFront

#8
post #3

If 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

#9

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.

Just change the Access-Control-Allow-Origin header. Am I missing something?

Re: Deploying front-end websites to S3 with CloudFront

#10
post #9

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.

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.
Post reply on HN