vibecode.wiki
RU EN
~/wiki / interfeis-i-sayty / podklychenie-domena-cloudflare

Connecting a domain to a site on Cloudflare

◷ 4 min read 2/15/2026

Next step

Open the bot or continue inside this section.

$ cd section/ $ open @mmorecil_bot

Article -> plan in AI

Paste this article URL into any AI and get an implementation plan for your project.

Read this article: https://vibecode.morecil.ru/en/interfeis-i-sayty/podklychenie-domena-cloudflare/ Work in my current project context. Create an implementation plan for this stack: 1) what to change 2) which files to edit 3) risks and typical mistakes 4) how to verify everything works If there are options, provide "quick" and "production-ready".
How to use
  1. Copy this prompt and send it to your AI chat.
  2. Attach your project or open the repository folder in the AI tool.
  3. Ask for file-level changes, risks, and a quick verification checklist.

Step 1. Preparation (once)

Buy a domain from Timeweb (or anywhere).

Create tokens:

Write down the values (can be in a notebook):

  • DOMAIN = your domain.ru
  • TW_TOKEN = eyJ.
  • CF_TOKEN = your cloudflare token
  • CF_ACCOUNT_ID = your Account ID (see Cloudflare dashboard)
  • CF_PROJECT = the exact name of your Pages project

Step 2. Safe migration through Codex

  1. Copy and paste this large prompt as the first message:
code
Your task is to conduct a safe domain migration to Cloudflare Pages in phase 2 using only curl commands.

Rules:
Always use only curl (no Python, Node, etc.).
- Never keep tokens. Use placeholders each time or ask the user to insert them again.
After each curl command, write: “Copy and execute this command in the terminal, then paste the full answer (JSON) here.”
- Work strictly on the steps below. Don't miss or join steps.
After each successful step, write “Step X is completed” and proceed to the next step only after the user responds.
If the user says “Start Phase 1,” start with Step 1.

Phase 1 (safe, no downtime):
1. Ask for all variables: DOMAIN, TW TOKEN, CF TOKEN, CF ACCOUNT ID, CF PROJECT.
2. Backup DNS from Timeweb: generate curl GET https://api.timeweb.cloud/api/v1/domains/$DOMAIN/dns-records
3. Save the current NS (GET /api/v1/domains/$DOMAIN/name-servers) for rollback.
4. Create a zone in Cloudflare: POST https://api.cloudflare.com/client/v4/zones with type=full.
5. Get zone id and name servers Cloudflare.
6. Transfer records: either generate a BIND zone file from JSON Timeweb and curl-import, or create each record a separate POST /zones/{zone id}/dns records.
7. Link the domain to Pages: two POSTs on /accounts/{CF ACCOUNT ID}/pages/projects/{CF PROJECT}/domains (domain.com and www.domain.com).

Phase 2 (switch):
8. Disable DNSSEC from the registrar (remind the user manually if enabled).
9. Change NS to Timeweb: PUT https://api.timeweb.cloud/api/v1/domains/$DOMAIN/name-servers with name servers Cloudflare.
10. Run the check cycle: every 15-20 seconds curl GET zone + dig NS + curl -I https://$DOMAIN
11. When Active Status - Enable DNSSEC in Cloudflare: PATCH /zones/{zone id}/dnssec {"status":"active}

If something goes wrong, offer a rollback.

Start only when the user says “start” or “start phase 1”.
  1. After inserting the prompt, write the AI:

"Start Phase 1"**

AI will start asking for tokens, generate the first curl command, and lead you to the end.

What will happen next

  • The AI itself parses all JSON answers.
  • When transferring DNS, it will either create a convenient BIND file and give a curl from --form file=@zone.txt, or make separate curl for each record (usually 5-15 pieces).
  • In Phase 2, it will check the activation of the zone and tell you when to activate DNSSEC.
  • If the domain is not registered directly in Timeweb (and the partner’s), the AI will remind you to manually change the NS in the registrar panel.

Important nuances (AI knows them too)

  • If changing NS through the Timeweb API is not available, the AI will tell you to change manually.
  • Transfer the registrar to Cloudflare Registrar only 24-48 hours after activation.
  • Everything is done with zero downtime – the site continues to work on the old NS until the switch.