How to set environment variables via `wrangler pages deploy` per deployment?

I managed to deploy a project with wranger pages deploy, but a function that is included there requires an environment variable - and optimally I could set that per deployment. Is that a thing for Pages? Or do I have to set it via the UI for all preview deployments?
2 Replies
DaniFoldi
DaniFoldi7mo ago
To my knowledge, pages only supports two sets of env variables, one for production (deployments from your main branch), and preview (every other branch). However, I'm not sure if changing it in the UI (you can look at what network requests it makes if you want it automated) affects previous deployments, as the docs https://developers.cloudflare.com/pages/platform/functions/bindings/#secrets all include redeploying for changes to take effect as the last step.
Jan Piotrowski (janpio)
Yeah, the UI actually says Changes will take effect on the next deployment. - so the new envs are only availalbe on next deploy.