Hire Lovable Xperts
Migration

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.

  1. Confirm your Lovable preview is working — only migrate a stable app.
  2. List every environment variable in Lovable Project Settings → Environment. You need all VITE_ prefixed values.
  3. Confirm your GitHub repo is connected to Lovable and the latest code is pushed.
  4. Check your vite.config.ts for the build output directory — for Vite projects it is dist by default, but some Lovable templates override it.
  5. If your app uses Supabase, note your Supabase project URL and anon key.
  6. 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.

Cloudflare Pages vs Vercel vs Netlify — key differences for Lovable apps
DimensionCloudflare PagesVercelNetlify
Edge network200+ PoPs, true edgeGlobal CDN + edge functionsGlobal CDN
Cold startsNone (V8 isolates)Near-zero (Node.js)Fast (Node.js)
Free bandwidthUnlimited100 GB/month100 GB/month
Server-side runtimeWorkers (V8, not Node)Vercel Functions (Node)Netlify Functions (Node)
Env var scopingPreview and Production separatelyPreview/Production/DevelopmentAll deploys or scoped
Build output dir for Vitedist (must confirm)dist (auto-detected)dist (usually auto-detected)
Instant rollbackRe-deploy previousOne clickOne click
Custom domainsVia Cloudflare DNS (easiest if already on CF)Any DNS providerAny 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.

  1. In Lovable, open Project Settings → GitHub and push your code to a new repo.
  2. Go to dash.cloudflare.com and select Workers & Pages → Create Application → Pages.
  3. Connect your GitHub account and select the Lovable repo.
  4. Set Build command: npm run build (or vite build if not using npm scripts).
  5. Set Build output directory: dist (Vite default — confirm by checking your vite.config.ts).
  6. 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.

Cloudflare Pages splits environment variables into plain text and secret. Add VITE_SUPABASE_URL as plain text and VITE_SUPABASE_ANON_KEY as a secret. Both must be set for production AND preview environments.

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.

  1. Copy your *.pages.dev URL from the Cloudflare Pages dashboard after the first deploy.
  2. In Supabase, go to Authentication → URL Configuration.
  3. Add the *.pages.dev URL to Redirect URLs.
  4. 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.

Cloudflare Pages error → cause → fix
Error / SymptomMost likely causeFix
Blank page after successful buildVITE_ env vars not set or set for Preview onlySet all VITE_ vars for both Production and Preview in Pages → Settings → Environment Variables
Build succeeds but all routes return 404Build output directory set to build instead of distChange Output Directory to dist in Pages build settings and redeploy
Auth callback fails / redirect loopSupabase Redirect URLs don't include *.pages.devAdd your *.pages.dev URL to Supabase → Authentication → URL Configuration → Redirect URLs
Env vars missing in production but present in previewVariables scoped to Preview environment onlyIn 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 availableReplace process.env.X with the Cloudflare env binding or use Vite's import.meta.env for client-side vars
Custom domain shows old Lovable siteDNS propagation lag or CNAME not pointed to CloudflareCheck DNS record points to your Pages project domain; wait for TTL to expire
Supabase edge function calls failEdge functions invoke Supabase — check CORS allowed originsAdd 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.

Cloudflare Pages has separate environment variable sets for Preview and Production. Set your env vars in both, or production deploys will be missing variables even if preview builds work.

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.

  1. In the Cloudflare dashboard, go to Workers & Pages → your project → Deployments.
  2. Find the last stable deployment and click the three-dot menu → Rollback to this deployment.
  3. 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.
  4. 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.

  1. Load the home page and check for console errors about undefined env vars — Cloudflare Preview/Production scoping is the most common source.
  2. Sign in with a Supabase account and hard-reload — confirm the session survives (Cloudflare caching headers can interfere with auth cookies).
  3. Open Cloudflare Pages → Functions → Real-time Logs and trigger a Worker function — confirm no 'process is not defined' or Node.js-specific errors.
  4. 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?
Yes. Most Lovable apps are Vite or React projects, and Cloudflare Pages detects them automatically. Set the build output directory to dist and the build command to npm run build. If Cloudflare auto-detects the wrong framework, override the settings manually.
Are Cloudflare Workers compatible with Supabase edge functions?
Supabase edge functions run on Supabase's Deno runtime — they are separate from Cloudflare Workers. If your Lovable app calls Supabase edge functions, they continue to work unchanged after you move to Cloudflare Pages, since they are invoked by the browser, not by your hosting layer.
What is the cost of hosting a Lovable app on Cloudflare Pages?
Cloudflare Pages has a generous free tier: unlimited sites, unlimited bandwidth, and 500 deploys per month. For most Lovable apps this is more than sufficient. The Workers Paid plan ($5/month) adds more compute for Worker-based server-side functions.
Can I preview the Cloudflare deploy before cutting DNS?
Yes. Every Cloudflare Pages deploy gets a unique *.pages.dev URL. Smoke-test your full app — auth, data reads, payment flows — on that URL before changing your DNS records. This lets you catch env-var and origin issues without affecting live users.
Why do my environment variables disappear after a Cloudflare redeploy?
Cloudflare Pages scopes environment variables to Preview and Production separately. If you set variables only for Preview, production deploys will not have them. Go to Pages → Settings → Environment Variables and ensure every VITE_ variable is set for the Production environment.
My Cloudflare build succeeds but every page returns a 404. Why?
The build output directory is almost certainly wrong. Vite outputs to dist by default, but if Cloudflare Pages is configured to look in build or public, every route returns 404 even though the build succeeded. Fix the Output Directory in Pages build settings to dist and redeploy.
Do Cloudflare Workers support Node.js APIs used by my Lovable app?
Cloudflare Workers run on V8 isolates, not Node.js. APIs like process.env, fs, and path are not available. For most Lovable apps this is fine because the frontend only uses browser APIs and Supabase's client library. If you add server-side Workers, avoid Node.js-specific APIs.
Can I keep editing in Lovable after moving to Cloudflare Pages?
Yes. Lovable commits changes to your GitHub repo, and Cloudflare Pages auto-deploys on each new commit. You can continue using Lovable's AI editor for feature work while hosting on Cloudflare — the two are independent.
How do I connect a custom domain on Cloudflare Pages if my DNS is already on Cloudflare?
If your domain is already using Cloudflare DNS, adding a custom domain to your Pages project is one step: Cloudflare automatically adds the CNAME record for you. If your DNS is on another provider (GoDaddy, Namecheap, etc.), you add a CNAME pointing to your Pages project URL manually.
What is the best way to preview a Cloudflare Pages deploy before going live?
Every Cloudflare Pages build gets a unique *.pages.dev URL that you can share and test without touching DNS. For branch deploys, Cloudflare also generates per-commit preview URLs. Smoke-test auth, Supabase data reads, and any Workers functions on the preview URL — then cut DNS only after everything passes.

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.

Book a free audit call