Workers - Select Wrangler environments using the CLOUDFLARE_ENV environment variable
7mo ago
Source
CloudflareWorkers - Select Wrangler environments using the CLOUDFLARE_ENV environment variablecloudflare.comWrangler now supports using the CLOUDFLARE_ENV environment variable to select the active environment for your Worker commands. This provides a more flexible way to manage environments, especially when working with build tools and CI/CD pipelines. What's new Environment selection via environment variable: Set CLOUDFLARE_ENV to specify which environment to use for Wrangler commands Works with all Wrangler commands that support the --env flag The --env command line argument takes precedence over the CLOUDFLARE_ENV environment variable Example usage # Deploy to the production environment using CLOUDFLARE_ENV CLOUDFLARE_ENV = production wrangler deploy # Upload a version to the staging environment CLOUDFLARE_ENV = staging wrangler versions upload # The --env flag takes precedence over CLOUDFLARE_ENV CLOUDFLARE_ENV = dev wrangler deploy --env production # This will deploy to production, not dev Use with build tools The CLOUDFLARE_ENV environment variable is particularly useful when working with build tools like Vite. You can set the environment once during the build process, and it will be used for both building and deploying your Worker: # Set the environment for both build and deploy CLOUDFLARE_ENV = production npm run build & wrangler deploy When using @cloudflare/vite-plugin , the build process generates a "redirected deploy config" that is flattened to only contain the active environment. Wrangler will validate that the environment specified matches the environment used during the build to prevent accidentally deploying a Worker built for one environment to a different environment. Learn more System environment variables Environments
You might also wanna read
Cloudflare expands AI bot management tools with granular traffic controls for all customers
Cloudflare is celebrating the second "Content Independence Day" by expanding AI traffic management options for all website owners. Building
Workers - Simpler runtime types with @cloudflare/workers-types v5
Cloudflare·1d ago
Cloudflare One - Hostname routing for Cloudflare Mesh
Cloudflare·2d ago
AI Search - Manage AI Search sync jobs with Wrangler CLI
Cloudflare·2d ago
Cache - Cache multiple versions of a URL with Vary
Cloudflare·2d ago
Workers - Work across multiple accounts with Wrangler auth profiles
Cloudflare·2d ago

Comments
Sign in to join the conversation.
No comments yet. Be the first.