Workers - Improved support for running multiple Workers with `wrangler dev`
9mo ago
Source
CloudflareWorkers - Improved support for running multiple Workers with `wrangler dev`cloudflare.comYou can run multiple Workers in a single dev command by passing multiple config files to wrangler dev : wrangler dev --config ./web/wrangler.jsonc --config ./api/wrangler.jsonc Previously, if you ran the command above and then also ran wrangler dev for a different Worker, the Workers running in separate wrangler dev sessions could not communicate with each other. This prevented you from being able to use Service Bindings and Tail Workers in local development, when running separate wrangler dev sessions. Now, the following works as expected: # Terminal 1: Run your application that includes both Web and API workers wrangler dev --config ./web/wrangler.jsonc --config ./api/wrangler.jsonc # Terminal 2: Run your auth worker separately wrangler dev --config ./auth/wrangler.jsonc These Workers can now communicate with each other across separate dev commands, regardless of your development setup. export default { async fetch ( request , env ) { // This service binding call now works across dev commands const authorized = await env . AUTH . isAuthorized ( request ) ; if ( ! authorized ) { return new Response ( "Unauthorized" , { status : 401 } ) ; } return new Response ( "Hello from API Worker!" , { status : 200 } ) ; }, }; Check out the Developing with multiple Workers guide to learn more about the different approaches and when to use each one.
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
AI Search - Manage AI Search sync jobs with Wrangler CLI
Cloudflare·2d ago
Workers - Work across multiple accounts with Wrangler auth profiles
Cloudflare·2d ago
Cache - Cache multiple versions of a URL with Vary
Cloudflare·2d ago
Cloudflare One - Hostname routing for Cloudflare Mesh
Cloudflare·2d ago

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