Buy Domain Helper
3 layers — pick the depth that fits the user's need:
| Layer | What it does | Needs |
|---|
| 1 — Tunnel | Instant public URL for any local dir or port | Nothing (cloudflared auto-installs) |
| 2 — Pages |
Permanent hosting on
*.pages.dev | Cloudflare account + Pages token |
|
3 — Domain | Custom domain linked to Pages via DNS | Domain purchased + DNS token |
Helper script
CODEBLOCK0
| Command | Layer | Description |
|---|
| INLINECODE1 | 1 | Instant public URL via Cloudflare Tunnel |
| INLINECODE2 |
2 | Deploy to Cloudflare Pages |
|
zone <domain> | 3 | Get zone ID for a domain |
|
dns-link <zone-id> <project> | 3 | Add CNAME pointing domain to Pages |
|
pages-domain <project> <domain> | 3 | Attach custom domain to Pages project |
|
domain-check <domain> | 3 | Check availability on Cloudflare Registrar |
Setup
- - Layer 1: No setup.
cloudflared installs automatically via Homebrew if missing. - Layer 2: Needs a Cloudflare API token with Account > Cloudflare Pages > Edit permission.
- Layer 3: Needs a separate token with Zone > DNS > Edit permission for the specific domain.
Create tokens at: https://dash.cloudflare.com/profile/api-tokens
域名购买助手
三层结构 — 根据用户需求选择合适层级:
| 层级 | 功能说明 | 所需条件 |
|---|
| 1 — 隧道 | 为任意本地目录或端口提供即时公网URL | 无需任何配置(cloudflared自动安装) |
| 2 — 页面 |
在 *.pages.dev 上提供永久托管 | Cloudflare账户 + Pages令牌 |
|
3 — 域名 | 通过DNS将自定义域名关联到Pages | 已购买域名 + DNS令牌 |
辅助脚本
bash
node site.js <命令> [--token CFAPITOKEN] [--account CFACCOUNTID]
| 命令 | 层级 | 描述 |
|---|
| tunnel <目录\ | 端口> | 1 | 通过Cloudflare隧道获取即时公网URL |
| deploy <名称> <目录> |
2 | 部署到Cloudflare Pages |
| zone <域名> | 3 | 获取域名的区域ID |
| dns-link <区域ID> <项目> | 3 | 添加指向Pages的CNAME域名记录 |
| pages-domain <项目> <域名> | 3 | 将自定义域名关联到Pages项目 |
| domain-check <域名> | 3 | 检查域名在Cloudflare注册商处的可用性 |
配置说明
- - 第1层:无需配置。若缺少cloudflared,将通过Homebrew自动安装。
- 第2层:需要具有账户 > Cloudflare Pages > 编辑权限的Cloudflare API令牌。
- 第3层:需要针对特定域名具有区域 > DNS > 编辑权限的独立令牌。
创建令牌地址:https://dash.cloudflare.com/profile/api-tokens