Cloudflare 🤯

November 15, 2022

I was trying to build a really simple redirector to get back into the mode of building and deploying things for real. It’s been a while - management and children don’t leave that much time for hacking on the side.

I started by building a simple thing with Go. I love Go. It’s simple and straightforward. I cheated. I used copilot to get me through rusty syntax. Copilot is amazing - easily worth the $10 per month. Got the go app built in about 15 mins (all it does is redirect rushabhdoshi.com/linkname to https://linktarget with a 301 or 302.)

Okay cool, lets deploy. Started with Google Cloud. I guess I still have some part of me that is loyal to Google and wants to start there first. Oh boy, what a mess. Cloud Workers are terrible, lots of versioning issues with the new version being mostly complete and the old version being deprecated (familiar to any Googler). DNS redirects not working. Yikes.

I dialed in the cavalry (aka my friend Brian.) He suggested looking at Cloudflare workers. I’d heard of them before without playing with them. Took another look.

Workers are super interesting. They deploy everywhere, in the same process. Only JS workers are supported because of this execution model. Anything that compiles to webasm neatly is fine (Rust, C++). Here is a great post by Kenton detailing why Go isn’t supported (and unlikely to be supported anytime soon.)

Okay, fine. It took about 15m to write the damn thing, how long can it take to rewrite it in JS? Turns out … about 15m. TS really, but samesies.

Deployment otoh - SO MUCH SIMPLER. Get the app up and running in one command. Fabulous. Now to fix DNS.

This opened up another rabbit hole - getting Cloudflare to be my default nameserver instead of Google. Fairly straightforward instructions. I had another toy domain that I wasn’t using, so tried that out first. Smooth as butter. 👏🏽👏🏽👏🏽 Cloudflare - I’m starting to get really impressed. Created a small website there - rad-labs.io - and deployed it. Whoa.

And then it turns out that Cloudflare has redirects built in. 🤯

Okay, so now we need to move this site off Github pages and on to Cloudflare. And add redirects. And Cloudflare autodeploys on commmit, so get rid of deploy.sh. ✅ ✅ ✅

Holy smokes. So over the space of an evening - 2 hours really - I’ve gone from zero to:

And it’s all free.

🫡 Cloudflare. You won me tonight.