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
oAuthbrowser authorization login publishingCLOUDFLARE_API_TOKEN+CLOUDFLARE_ACCOUNT_ID
- The
oAuthpublishing method uses your local account login, requiring browser authorization to proceed with thepublishingaction.
wrangler login
This will launch a browser window, guiding you through the OAuth login process for Cloudflare.
- For
CLOUDFLARE_API_TOKENpublishing, you only need to create a new.envfile locally
CLOUDFLARE_API_TOKEN=""
CLOUDFLARE_ACCOUNT_ID=""
Important Notes
- When using
CLOUDFLARE_API_TOKENfor 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->Readpermission?) This can be resolved by using localwrangler loginauthorization.
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.