Multiple Account Publishing Issues with Cloudflare Pages

Implementing multi-account publishing with Cloudflare Pages
2025-4-18
cloud flare pagewranglerwrangler pages deploy
Problem Description
Cloudflare uses wrangler
for local publishing and login. How can we switch between multiple accounts?
Wrangler Publishing Methods
oAuth
browser authorization login publishingCLOUDFLARE_API_TOKEN
+CLOUDFLARE_ACCOUNT_ID
- The
oAuth
publishing method uses your local account login, requiring browser authorization to proceed with thepublishing
action.
wrangler login
This will launch a browser window, guiding you through the OAuth login process for Cloudflare.
- For
CLOUDFLARE_API_TOKEN
publishing, you only need to create a new.env
file locally
CLOUDFLARE_API_TOKEN=""
CLOUDFLARE_ACCOUNT_ID=""
Important Notes
- When using
CLOUDFLARE_API_TOKEN
for local publishing for the first time, you might encounter: (π You are logged in with an API Token. Unable to retrieve email for this user. Are you missing theUser->User Details->Read
permission?) This can be resolved by using localwrangler login
authorization.
Problem Description
How to handle multi-branch publishing with Cloudflare Pages?
Solution
- Use the following commands
wrangler pages deploy --branch=main // deploy to main branch
wrangler pages deploy --branch=develop // deploy to development branch
Important Notes
- When initializing the project, pay attention to specifying the main branch name correctly the first time. This cannot be changed later, and you would need to delete and recreate the project if it's wrong.