How to Move a Lovable App to Cloudflare
Cloudflare Pages deploys to a global edge network with no cold starts and an unlimited free bandwidth tier. The migration from Lovable mirrors Vercel's, but the build-output directory, environment variable scoping, and Workers runtime differ in ways that trip up first-time deployers. This guide covers every step including the Supabase allowed-origin update that causes most silent auth failures.
By Founder Name · Last verified: 2026-06-24
Before you start: what to have ready
A Cloudflare migration that fails does so in the first five minutes — almost always because of missing env vars or a wrong output directory. Checking these prerequisites before you touch the Cloudflare dashboard saves a full debug cycle. Work through this list now.
- Confirm your Lovable preview is working — only migrate a stable app.
- List every environment variable in Lovable Project Settings → Environment. You need all VITE_ prefixed values.
- Confirm your GitHub repo is connected to Lovable and the latest code is pushed.
- Check your vite.config.ts for the build output directory — for Vite projects it is dist by default, but some Lovable templates override it.
- If your app uses Supabase, note your Supabase project URL and anon key.
- If your app uses Stripe webhooks, note the current webhook endpoint URL — you will need to update it after DNS cutover.
Why choose Cloudflare Pages over Vercel or Netlify?
Cloudflare Pages serves assets from Cloudflare's global edge with no origin server and no cold-start delays. For Lovable apps that are primarily static or use Supabase for all data operations, this means fast load times worldwide with an unlimited-bandwidth free tier. The trade-off is that Cloudflare Workers uses a V8 isolate runtime rather than Node.js, which matters if you add server-side functions.
| Dimension | Cloudflare Pages | Vercel | Netlify |
|---|---|---|---|
| Edge network | 200+ PoPs, true edge | Global CDN + edge functions | Global CDN |
| Cold starts | None (V8 isolates) | Near-zero (Node.js) | Fast (Node.js) |
| Free bandwidth | Unlimited | 100 GB/month | 100 GB/month |
| Server-side runtime | Workers (V8, not Node) | Vercel Functions (Node) | Netlify Functions (Node) |
| Env var scoping | Preview and Production separately | Preview/Production/Development | All deploys or scoped |
| Build output dir for Vite | dist (must confirm) | dist (auto-detected) | dist (usually auto-detected) |
| Instant rollback | Re-deploy previous | One click | One click |
| Custom domains | Via Cloudflare DNS (easiest if already on CF) | Any DNS provider | Any DNS provider |
How do I connect my Lovable repo to Cloudflare Pages?
First connect Lovable to GitHub so your code lives in a repository, then import that repo in the Cloudflare Pages dashboard. Cloudflare auto-detects most Vite projects, but you may need to manually set the build command and output directory if auto-detection picks the wrong preset.
- In Lovable, open Project Settings → GitHub and push your code to a new repo.
- Go to dash.cloudflare.com and select Workers & Pages → Create Application → Pages.
- Connect your GitHub account and select the Lovable repo.
- Set Build command: npm run build (or vite build if not using npm scripts).
- Set Build output directory: dist (Vite default — confirm by checking your vite.config.ts).
- Add environment variables before clicking Save and Deploy.
Which environment variables do I need to copy from Lovable?
Lovable stores your Supabase credentials and any other secrets as VITE_ prefixed variables in its build environment. When you move to Cloudflare Pages, those variables must be added to the Cloudflare dashboard before the first deploy or your Supabase client will initialise with undefined values and the app will appear blank.
How do I update Supabase to allow the Cloudflare Pages domain?
After your first Cloudflare deploy, you will have a *.pages.dev URL. Add it to Supabase Authentication → URL Configuration → Redirect URLs before testing any auth flows. Auth calls from an unlisted origin are rejected by Supabase, which looks like a successful deploy that fails silently on login.
- Copy your *.pages.dev URL from the Cloudflare Pages dashboard after the first deploy.
- In Supabase, go to Authentication → URL Configuration.
- Add the *.pages.dev URL to Redirect URLs.
- After DNS cutover, add your custom domain to the same list.
Common Cloudflare Pages errors and fixes
Cloudflare Pages surfaces errors differently from Vercel and Netlify. Build failures appear in the Pages deployment log; runtime errors appear only in the browser console or Cloudflare Workers logs. The table below covers the most common issues reported by teams migrating Lovable apps.
| Error / Symptom | Most likely cause | Fix |
|---|---|---|
| Blank page after successful build | VITE_ env vars not set or set for Preview only | Set all VITE_ vars for both Production and Preview in Pages → Settings → Environment Variables |
| Build succeeds but all routes return 404 | Build output directory set to build instead of dist | Change Output Directory to dist in Pages build settings and redeploy |
| Auth callback fails / redirect loop | Supabase Redirect URLs don't include *.pages.dev | Add your *.pages.dev URL to Supabase → Authentication → URL Configuration → Redirect URLs |
| Env vars missing in production but present in preview | Variables scoped to Preview environment only | In Pages → Settings → Environment Variables, set each variable for Production as well |
| Worker function throws 'ReferenceError: process is not defined' | Cloudflare Workers uses V8 runtime, not Node.js — process is not available | Replace process.env.X with the Cloudflare env binding or use Vite's import.meta.env for client-side vars |
| Custom domain shows old Lovable site | DNS propagation lag or CNAME not pointed to Cloudflare | Check DNS record points to your Pages project domain; wait for TTL to expire |
| Supabase edge function calls fail | Edge functions invoke Supabase — check CORS allowed origins | Add your Cloudflare domain to Supabase → Edge Functions → allowed origins if applicable |
What are the most common gotchas when migrating to Cloudflare Pages?
The four most common issues are: missing env vars (blank page), Supabase origin not updated (auth 403), the build output directory set to build instead of dist (deploy succeeds but returns 404), and vanishing env vars after a re-deploy because they were only set for the Preview environment and not Production. Double-check all four before cutting DNS.
How do I roll back if the Cloudflare Pages migration breaks?
Cloudflare Pages retains every deployment and lets you restore any previous build via the dashboard — no rebuild needed. If your DNS is already managed by Cloudflare, rolling back a domain cutover is a single record change that propagates in seconds on Cloudflare's own network, which is faster than waiting for external DNS TTLs to expire.
- In the Cloudflare dashboard, go to Workers & Pages → your project → Deployments.
- Find the last stable deployment and click the three-dot menu → Rollback to this deployment.
- If your DNS is on Cloudflare, edit the CNAME record in DNS back to Lovable's hostname — the change propagates within seconds on Cloudflare's network.
- If DNS is on an external provider (GoDaddy, Namecheap), update the CNAME there and allow for propagation delay.
How do I handle auth password hashes when moving to a new Supabase project?
If you are migrating to a fresh Supabase project (not reusing the same one), Supabase auth password hashes cannot be exported or transferred. Users will not be able to log in with their existing passwords. Send a password-reset email to all users before cutting DNS, and communicate the reset in advance so users expect it.
Post-migration smoke test for Cloudflare Pages
Cloudflare's V8 isolate runtime behaves differently from Node.js, which means some issues only appear after deploy and not during local testing. Run this checklist on your *.pages.dev URL to catch Workers-specific failures — especially missing environment variables and process-not-defined errors — before any live user traffic hits the new domain.
- Load the home page and check for console errors about undefined env vars — Cloudflare Preview/Production scoping is the most common source.
- Sign in with a Supabase account and hard-reload — confirm the session survives (Cloudflare caching headers can interfere with auth cookies).
- Open Cloudflare Pages → Functions → Real-time Logs and trigger a Worker function — confirm no 'process is not defined' or Node.js-specific errors.
- Verify Supabase Redirect URLs include both your *.pages.dev URL and your custom domain before declaring the migration complete.
Frequently asked questions
Does Cloudflare Pages support Vite projects from Lovable?
Are Cloudflare Workers compatible with Supabase edge functions?
What is the cost of hosting a Lovable app on Cloudflare Pages?
Can I preview the Cloudflare deploy before cutting DNS?
Why do my environment variables disappear after a Cloudflare redeploy?
My Cloudflare build succeeds but every page returns a 404. Why?
Do Cloudflare Workers support Node.js APIs used by my Lovable app?
Can I keep editing in Lovable after moving to Cloudflare Pages?
How do I connect a custom domain on Cloudflare Pages if my DNS is already on Cloudflare?
What is the best way to preview a Cloudflare Pages deploy before going live?
Talk to a senior engineer — not a salesperson.
Book a free 30-minute audit call. We'll diagnose what's wrong and tell you exactly what it costs to fix.