OneBite.Dev - Coding blog in a bite size

Migrating my static sites from Vercel to Cloudflare pages

I have many static site generated websites. I moved them from Vercel to Cloudflare pages

I’ve been using Vercel for a long time. Most of my experiments are hosted here. Curious to see what other platforms offer.

I tried railway.com at first, until I saw the Cloudflare pages generous pricing.

I was struggling at first with some websites. Most of them just because a different package version here and there. Once the version is corrected, it’s all good!

Yarn version For example, my Yarn version is much behind locally, it turns out it became a proble. So, I should specify on my package.json file. For example:

"packageManager": "yarn@1.22.18",

Nodejs version Another examples is the Node version. For this, we need to set the environment variable with: NODE_VERSION as key, and whatever version of your projects’ Nodejs as the value.

Redirects Some of my websites have redirect rules that previously on vercel.json file. Now, I have to declare it on the _redirects file on the public folder or wherever your root folder is.

Please refer to Cloudflare redirects documentation.

External redirects For path that redirect to external websites, I have to use the page rules.

Again, pelase refer to Cloudlfare page rules documentation

cloudflare