Simple CLI using Cloudflare API and Workers to deploy a maintenance page to a domain
Install Bun runtime
Install the CLI globally:
bun i -g cloudflare-maintenance-page-cli
Then use the command cfmp anywhere.
Or run without installing globally:
bunx cloudflare-maintenance-page-cli <command>
cfmp deploy - deploys the maintenance page worker to Cloudflare at /maintenance on your domaincfmp enable - enables maintenance mode (routes all traffic to the worker)cfmp disable - disables maintenance mode (back to normal)At the first run, it will create ~/.config/cloudflare-maintenance-page-cli/config.json, then prompt for your Cloudflare information:
To edit the config, just run cfmp config.
Your API token is NOT stored in plain text in the config file. It is stored securely using the operating system’s keychain. To delete it, you can run
cfmp config --delete.
The config has two sections:
CLOUDFLARE - your Cloudflare informationPAGE - customize the maintenance pageYou can also use environment variables (example
CLOUDFLARE_ACCOUNT_ID=your_id... cfmp deploy). This doesn’t apply to the token.
The CLI will deploy a Cloudflare Worker on your Cloudflare account named maintenance-<domain>-<start_of_zone_id>.
Cloudflare Workers limits apply according to your plan. See Cloudflare Workers limits.
To install dependencies:
bun install
To link globally:
bun link
Then use cfmp anywhere.
This project was created using bun init in bun v1.2.19. Bun is a fast all-in-one JavaScript runtime.