First post
by chansiky
First post! Check out my new static Next.js blog!
In my naivety I thought getting this simple website revved up would be a small task. Somehow these things are always way more work than you expect.
The plan was simple:
- Fork a RealWorld app backend/frontend picking and choosing frameworks/languages I want to use
- Tweak the repo with small changes to suit my taste
- Upload it to s3, following verbatim instructions to serve a static website on AWS Cloudfront
- Slap my name and logo, and call it a day
Unfortunately, what I thought would be a simple weekend project, ended up dragging on one issue after the next. After I fixed one problem, I found another, on and on this went. Since you might be thinking: What could be so hard, its just a static website? And it wasn't so much that it was hard, as it was a lot of tedious fixes and edits I didn't sign up for. Just as an example, here are some of the issues I came up against:
- Because the sample next.js code I was working with served pages from the server, I had to refactor the pages to generate pages statically.
- Static pages however meant query params would no longer work. Thus I had to rewrite how the dynamic pages were generated and then make decisions on how to get pages to list articles without query params (I chose to put each page into its own directory).
- Once the site was finally exportable statically, I thought it would just be an easy path to upload
to s3. Unfortunately while the initial load and click throughs were fine, if I refreshed the page,
cloudfront would reject the request because the url path wasn't an exact match to the files on s3
as s3 technically doesn't have folders. To solve this issue I ended up:
- Exporting dynamic pages with an
index.html
page using thetrailingSlash
configuration. - Adding a Cloudfront function to transform the request coming in through the url.
- Exporting dynamic pages with an
- Because my domain name existed outside of the aws ecosystem I had to set up name servers on my dns provider linking back to the aws ecosystem. But things just didn't seem to work. The worst part of this process was waiting to see if everything is linked up properly as those things just take time to propagate. And if it didn't work, maybe it was simply because I didn't wait long enough. Ultimately, my patience wore thin, and I just ended up buying a new domain name from Route53, and using that instead.
Alas...
Good news is, the site is up and running. While it was bit more work than I expected I'd say it was worth it for me. The best thing is, if I really wanted to add features or adjust my blog, the sky really is the limit given the foundations in place. There have been pointless things I've wanted to experiment with, so maybe I'll make good on that ambition one day. For now, I'm happy where its at even if it was a lot more than just a casual weekend churn.
Lets just say I took the scenic route.