How to fix: Cloudflare Pages Worker fetch() returns "error code: 1016" for Supabase REST API, only from DFW edge
This Supabase/Next.js failure usually means the edge runtime cannot reliably resolve or reach the Supabase host before auth or RLS is involved. Compare the same query from Node or Vercel, isolate affected Cloudflare routes, and move data fetches off the failing edge path.
This pattern is common in AI-built Next.js and Supabase apps because generated code often leaves auth, cookie, deployment, or type boundaries unfinished. The exact symptom matters, so preserve the original error before changing code.
Why it happens
The failure appears before Supabase auth/RLS: a Cloudflare edge location cannot resolve or route the Supabase hostname reliably.
What to check
Confirm all tables fail from the same colo and that other colos succeed with the same API key.
Log `colo`, hostname, and fetch target without printing credentials.
Test the same query from a Node/Vercel runtime to separate app code from edge DNS behavior.
Check whether Cloudflare Smart Placement or route config is pinning execution to the failing colo.
Fix plan
Move Supabase server fetches off Cloudflare edge runtime for affected routes, or proxy them through a stable Node runtime.
Keep public static pages on Cloudflare if needed, but isolate auth/data fetches where DNS is stable.
Add retry only after confirming this is transient; do not hide persistent edge DNS failure behind retries.
Smoke from multiple regions or runtimes before declaring the production path fixed.
When to stop guessing
If this touches auth, RLS, database writes, storage, redirects, or deployment callbacks, a build-only fix is not enough. Verify the real user path against the same Supabase project and domain that failed.
Need a second set of eyes? Paste the exact error into the free diagnosis form and get a focused rescue plan before you spend more time guessing.