Tired of losing sales because the little API that powers your online booking form goes dark after a power outage? I felt the same when a storm knocked out the power at my house in Pompano Beach and my site started throwing errors. Here’s the no‑fluff setup I use so the API stays reachable without spending a dime on a full‑time server.
Expose the API with a Cloudflare Tunnel – I install
cloudflaredon my Raspberry Pi, runcloudflared tunnel run my‑home‑api, and let Cloudflare give me a stablehttps://<random>.trycloudflare.comendpoint. The tunnel reconnects automatically when power returns, so the public URL never changes.Add a Netlify serverless function as a proxy – Netlify lets me create a tiny JavaScript function (
netlify/functions/api-proxy.js). It receives the request from my site, forwards it to the Cloudflare URL, and returns the response. Because Netlify runs the function on their edge network, the call is fast and the public URL of the function (https://my‑site.netlify.app/.netlify/functions/api-proxy) never moves.Health‑check & auto‑restart – A simple cron job on the Pi hits
https://my‑site.netlify.app/.netlify/functions/api-proxy/health. If it gets a non‑200 response, the script runssystemctl restart cloudflared. This keeps the tunnel alive even after a brief power hiccup.
That’s it – three tiny pieces, no extra hosting costs, and my booking form stays online even when the lights go out.
I build sites and automations for small businesses at dreamfuturestech.com.
